Commit 9ac8e8d5 authored by Patrick's avatar Patrick

better ignores for temp files

parent 730cf6f5
# Leave compiled files
*.pdf
# ignore the presentation lock file
.~lock.*.odp#
# don't take editor temp files
*~
*.swp
*.swo
#include <red_peg.h>
red_peg RP;
void setup() {
Serial.begin(BAUD);
RP.begin();
}
void loop() {
RP.sensorsOn();
t_SensorData depth = RP.get(MA4_20);
RP.sensorsOff();
if (depth.sensor == MA4_20) {
Serial.print("Value: ");
Serial.print(depth.reading);
Serial.print(", ");
Serial.print(RP.mA(depth));
Serial.print(" mA, ");
Serial.print(RP.level(depth, 7000));
Serial.print(" mm");
Serial.println();
} else {
Serial.println("no return from ADC");
}
delay(1000);
}
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include <red_peg.h>
red_peg RP;
void setup () {
Serial.begin(115200);
Serial.println(F("start rp_rtc_ds1307"));
RP.begin();
}
void loop () {
RP.sensorsOn();
delay(100);
t_SensorData the_time = RP.get(RTC);
RP.sensorsOff();
if (the_time.sensor == RTC) {
// print the current time in ISO 8601 format
Serial.print(the_time.y);
Serial.print("-");
Serial.print(the_time.m);
Serial.print("-");
Serial.print(the_time.d);
Serial.print("T");
Serial.print(the_time.hh);
Serial.print(":");
Serial.print(the_time.mm);
Serial.print(":");
Serial.print(the_time.ss); // DS1307 has whole secconds only
// assume UTC timestamp
Serial.print("Z");
Serial.println();
} else {
Serial.println(F("no RTC message received. \nLast message is:"));
RP.print_data(the_time);
}
delay(5000);
}
#include <red_peg.h>
red_peg RP;
void setup() {
Serial.begin(BAUD);
RP.begin();
}
void loop() {
t_SensorData temp_sensor = RP.get(TMP);
if (temp_sensor.the_sensor == TMP) {
Serial.print("Value: ");
Serial.print(temp_sensor.reading);
Serial.print(", ");
Serial.print(RP.volts(temp_sensor));
Serial.print("V, ");
Serial.print(RP.degC(temp_sensor));
Serial.print(" degC");
Serial.println();
} else {
Serial.println("no return from TMP");
}
delay(5000);
}
#include <Wire.h>
#include <RTClib.h>
RTC_DS1307 rtc;
#define SENSOR_ACTIVE_PIN 6
#define READING_DELAY 10000
uint32_t last_reading = READING_DELAY;
void setup()
{
Serial.begin(115200);
Serial.println(F("starting set_the_time"));
// check we have an RTC attached
if (!rtc.begin()) {
Serial.println(F("no RTC"));
die();
}
reportTimeNow();
Serial.println(F("To set the time send \"T YYYY MM DD hh mm ss\""));
}
void loop()
{
if (Serial.available()) {
// if we have serial input, check input for setting the time
setTime();
}
}
void setTime() {
char c = Serial.read();
if (c == 't' || c == 'T') {
uint16_t year;
uint8_t month, day, hour, min, sec;
Serial.print(F("Year: "));
year = Serial.parseInt();
Serial.println(year);
Serial.print(F("Month: "));
month = Serial.parseInt();
Serial.println(month);
Serial.print(F("Day: "));
day = Serial.parseInt();
Serial.println(day);
Serial.print(F("Hour: "));
hour = Serial.parseInt();
Serial.println(hour);
Serial.print(F("Minute: "));
min = Serial.parseInt();
Serial.println(min);
Serial.print(F("Second: "));
sec = Serial.parseInt();
Serial.println(sec);
rtc.adjust(DateTime(year, month, day, hour, min, sec));
Serial.print(F("RTC set to: "));
reportTimeNow();
}
}
void die() {
pinMode(LED_BUILTIN, OUTPUT);
while(1) {
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
}
void reportTimeNow() {
DateTime now = rtc.now();
char buf[5];
sprintf(buf, "%04d", now.year());
Serial.print(buf);
Serial.write('-');
sprintf(buf, "%02d", now.month());
Serial.print(buf);
Serial.write('-');
sprintf(buf, "%02d", now.day());
Serial.print(buf);
Serial.write('T');
sprintf(buf, "%02d", now.hour());
Serial.print(buf);
Serial.write(':');
sprintf(buf, "%02d", now.minute());
Serial.print(buf);
Serial.write(':');
sprintf(buf, "%02d", now.second());
Serial.print(buf);
Serial.write('Z');
Serial.println();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment