Browse Source

Merge branch 'nano-revision-2.1' into nano-revision-2.2

nano-revision-2.2
Stephan Richter 10 months ago
parent
commit
74a5cfa41c
  1. 26
      Software/LCDReceiver/LCDReceiver.ino
  2. 8
      Software/TempSender/TempSender.ino

26
Software/LCDReceiver/LCDReceiver.ino

@ -23,17 +23,15 @@
#define PROGRAM "RS485-Nano 2.2 / LCDReceive 1.2" #define PROGRAM "RS485-Nano 2.2 / LCDReceive 1.2"
// initialize the library by associating any needed LCD interface pin with the arduino pin number it is connected to // initialize the library by associating any needed LCD interface pin with the arduino pin number it is connected to
LiquidCrystal lcd(LCD_RS, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7); LiquidCrystal lcd(LCD_RS, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7);
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
init485(Max485_RO,Max485_RE,Max485_DE,Max485_DI); // library initialization: init485(Max485_RO,Max485_RE,Max485_DE,Max485_DI); // library initialization:
//invert485polarity(true);
// set up the LCD's number of columns and rows: // set up the LCD's number of columns and rows:
lcd.begin(16, 2); lcd.begin(16, 4);
// Print a message to the LCD. // Print a message to the LCD.
printMessage(PROGRAM); printMessage(PROGRAM);
@ -42,13 +40,19 @@ void setup() {
void printMessage(String s){ void printMessage(String s){
Serial.println(s); Serial.println(s);
lcd.clear(); lcd.clear();
lcd.setCursor(0, 0); int line = 0;
lcd.print(s); int col = 0;
if (s.length()>16) { auto cstr = s.c_str();
lcd.setCursor(0, 1); for (int i=0;i<s.length();i++){
s=s.substring(16); if (col == 0 && cstr[i] == ' ') continue;
s.trim(); if (cstr[i] == '{' || cstr[i] == '}') continue;
lcd.print(s); lcd.print(cstr[i]);
col++;
if (cstr[i]==',' || col==16){
line++;
col=0;
lcd.setCursor(col, line);
}
} }
} }

8
Software/TempSender/TempSender.ino

@ -12,7 +12,7 @@
#include <SoftRS485.h> #include <SoftRS485.h>
#include <AM2302-Sensor.h> #include <AM2302-Sensor.h>
#define PROGRAM "RS485-Nano 2.2 / TempSender 1.2" #define VERSION "1.2"
#define BTN_INT 3 // button interrupt pin #define BTN_INT 3 // button interrupt pin
#define Max485_RO 2 // read-output of Max485 #define Max485_RO 2 // read-output of Max485
@ -39,7 +39,7 @@ boolean raw_states[8];
boolean states[8]; boolean states[8];
unsigned long capacitor[8]; unsigned long capacitor[8];
unsigned long times[8]; unsigned long times[8];
unsigned long sensor_time = PERIOD; unsigned long sensor_time = 0;
void setup(){ void setup(){
@ -63,7 +63,9 @@ void setup(){
attachInterrupt(digitalPinToInterrupt(BTN_INT),isr,CHANGE); attachInterrupt(digitalPinToInterrupt(BTN_INT),isr,CHANGE);
// Print a message to the LCD. // Print a message to the LCD.
Serial.println(PROGRAM); String s = "{nano:"+String(ID)+",revision:2.2,TempSender:"+VERSION+"}";
Serial.println(s);
send485(s.c_str());
#ifdef LOG_TO_SERIAL #ifdef LOG_TO_SERIAL
Serial.println("14 15 16 17 18 19 20 21"); Serial.println("14 15 16 17 18 19 20 21");
#endif #endif

Loading…
Cancel
Save