void setup() { Serial.begin(9600); //while(!Serial.available()) Particle.process(); //nextion.setBrightness(DISPLAY_BRIGHTNESS); /* BUTTON - WILL BE REMOVED LATER */ pinMode(D4, INPUT_PULLUP); // Setup button timers (all in milliseconds / ms) // (These are default if not set, but changeable for convenience) button1.debounceTime = 20; // Debounce timer in ms button1.multiclickTime = 250; // Time limit for multi clicks button1.longClickTime = 1000; // time until "held-down clicks" register // Subscribing for sensor data Particle.subscribe("Outside_Temperature", dataHandler, MY_DEVICES); Particle.subscribe("Outside_Humidity", dataHandler, MY_DEVICES); // Subscribing for weather data API call Particle.subscribe(HOOK_RESP, processWeatherData, MY_DEVICES); /* Set the baudrate which is for debug and communicate with Nextion screen. */ nexInit(); /* Register the pop event callback functions for the button components. */ b0.attachPop(b0PopCallback); b1.attachPop(b1PopCallback); b2.attachPop(b2PopCallback); bt0.attachPop(bt0PopCallback, &bt0); bt1.attachPop(bt1PopCallback, &bt1); n0.attachPop(n0PopCallback); n1.attachPop(n1PopCallback); bu0.attachPop(bu0PopCallback); u0.attachPop(u0PopCallback); // See if this EEPROM has saved data if(EEPROM.read(0)==117) { // Set language if(EEPROM.read(1)==1) { langCode = 1; bt0.setValue((uint32_t)langCode); } else { langCode = 0; } // Set temperature scale if(EEPROM.read(2)==1) { tempScale = 1; bt1.setValue((uint32_t)tempScale); } else tempScale = 0; } else { // Initialize EEPROM.write(0, 117); // Language EEPROM.write(1, 0); // Temperature scale EEPROM.write(2, 0); } // Set timezone Time.zone(TIMEZONE_OFFSET); // Set current day of the week currentWeekday = Time.weekday(); renderScreen(HOME_SCREEN); }
void lcd_init() { HAL::delayMilliseconds(2000); for (uint8_t i = 0; i < 10; i++) { NextionON = nexInit(); if (NextionON) break; delay(1000); } if (!NextionON) { ECHO_LM(DB, "Nextion LCD not connected!"); } else { ECHO_LM(DB, "Nextion LCD connected!"); Pstart.attachPop(ExitPopCallback); Exit1.attachPop(ExitPopCallback); Exit3.attachPop(ExitPopCallback); #if ENABLED(NEXTION_GFX) gfx.color_set(VC_AXIS + X_AXIS, 63488); gfx.color_set(VC_AXIS + Y_AXIS, 2016); gfx.color_set(VC_AXIS + Z_AXIS, 31); gfx.color_set(VC_MOVE, 2047); gfx.color_set(VC_TOOL, 65535); #endif #if ENABLED(SDSUPPORT) MSD1.attachPop(setpageSDPopCallback); MSD3.attachPop(setpageSDPopCallback); MSD5.attachPop(setpageSDPopCallback); MSD6.attachPop(setpageSDPopCallback); sdlist.attachPop(sdlistPopCallback); ScrollUp.attachPop(sdlistPopCallback); ScrollDown.attachPop(sdlistPopCallback); Exit2.attachPop(ExitPopCallback); NPlay.attachPop(PlayPausePopCallback); NStop.attachPop(StopPopCallback); #endif #if HAS_TEMP_0 hot0.attachPop(hotPopCallback, &hot0); #endif #if HAS_TEMP_1 hot1.attachPop(hotPopCallback, &hot1); #endif #if HAS_TEMP_2 || HAS_TEMP_BED hot2.attachPop(hotPopCallback, &hot2); #endif Fanpic.attachPop(setfanPopCallback, &Fanpic); m11.attachPop(sethotPopCallback, &m11); tup.attachPop(settempPopCallback, &tup); tdown.attachPop(settempPopCallback, &tdown); XYHome.attachPop(setmovePopCallback); XYUp.attachPop(setmovePopCallback); XYRight.attachPop(setmovePopCallback); XYDown.attachPop(setmovePopCallback); XYLeft.attachPop(setmovePopCallback); ZHome.attachPop(setmovePopCallback); ZUp.attachPop(setmovePopCallback); ZDown.attachPop(setmovePopCallback); SpeedOk.attachPop(ExitPopCallback); Benter.attachPop(setgcodePopCallback); startimer.enable(); } }