void updateUptime() { if (15 * 60 * 1000000 <= sinceUptime) { ++uptime; (void) EEPROM_writeAnything(0, uptime); sinceUptime = 0; } }
void sortData(char *chn, char *red, char *grn, char *blu, char *mode, char *audB, char *audS, char *unic, char *save) { int chan = atoi(chn); int arr = atoi(red); int gee = atoi(grn); int bee = atoi(blu); int emm = atoi(mode); int bnd = atoi(audB); int ess = atoi(audS); int uni = atoi(unic); data[chan][0] = chan; data[chan][1] = arr; // Convert the characters to integers from serial data (red) data[chan][2] = gee; // the green value data[chan][3] = bee; // blue data[chan][4] = emm; // the modes are commented in at the bottom data[chan][5] = bnd; // audio frequency band data[chan][6] = ess; // audio sensitivity data[chan][7] = uni; // int keep = atoi(save); // We should save immediately after this if keep > 1 if(keep > 0) { EEPROM_writeAnything(0, configuration); keep = 0; } }
void edit_waypoint(){ while(1){ display_waypoints(); SERIAL_OUT.println(); SERIAL_OUT.print("Edit wp #? "); int i = SERIAL_OUT.parseInt(); EEPROM_readAnything(i*WP_SIZE, waypoint); SERIAL_OUT.println(); SERIAL_OUT.print("current values: "); SERIAL_OUT.print(waypoint.x); SERIAL_OUT.print(" , "); SERIAL_OUT.println(waypoint.y); SERIAL_OUT.println(); SERIAL_OUT.print("enter new coordinates \"x , y\": "); int x_temp = SERIAL_OUT.parseInt(); int y_temp = SERIAL_OUT.parseInt(); SERIAL_OUT.println(); SERIAL_OUT.print("current values: "); SERIAL_OUT.print(waypoint.x); SERIAL_OUT.print(" , "); SERIAL_OUT.println(waypoint.y); SERIAL_OUT.print("new values: "); SERIAL_OUT.print(x_temp); SERIAL_OUT.print(" , "); SERIAL_OUT.println(y_temp); while(1){ SERIAL_OUT.print("accept values (y=1, n=0)? "); int y_or_n = SERIAL_OUT.parseInt(); if(y_or_n == 1){ waypoint.x = float(x_temp); waypoint.y = float(y_temp); EEPROM_writeAnything(i*WP_SIZE, waypoint); SERIAL_OUT.println(); SERIAL_OUT.println("waypoint changed"); break; } else if(y_or_n == 0){ SERIAL_OUT.println("no change made"); break; } else SERIAL_OUT.println("invalid. try again"); } SERIAL_OUT.println(); SERIAL_OUT.print("edit another waypoint (y=1, n=0)? "); int n_or_y = SERIAL_OUT.parseInt(); if(n_or_y == 1) ; else break; } SERIAL_OUT.println(); return ; }
//Populate the keychain with keys that could never be properly entered void Keychain::PopulateKeychain() { //Iterate through the keychain, reseting each key for(int i = 0; i < KEYCHAIN_KEY_COUNT; i++) Keys[i] = DEFAULT_EMPTY_KEY; WriteNewKeychain(); //Re-write the Keychain to the EEPROM //Set the flag marking the keychain as available from the EEPROM bool NowPopulated = true; EEPROM_writeAnything(KEYCHAIN_EXISTS_IN_EEPROM_FLAG_ADDRESS, NowPopulated); }
bool YaesuRotor::saveSettings() { bool result = false; unsigned int bytesWritten = EEPROM_writeAnything(CONFIG_EEPROM_ADDRESS, config); if(bytesWritten == sizeof(rotorConfig)) { result = true; } else { // write failed, try and reset the config save flag just in case that was written. // this prevents future load calls from trying to load an undefined config. EEPROM.write(CONFIG_EEPROM_ADDRESS, 0x00); } return result; }
//PROGRAM FUNCTIONS void set_waypoint(){ //CLEAR waypoint.x = x; waypoint.y = y; //waypoint.last = false EEPROM_writeAnything(wpw_count*WP_SIZE, waypoint); SERIAL_OUT.print("set WP #"); SERIAL_OUT.print(wpw_count); SERIAL_OUT.print(": "); SERIAL_OUT.print(waypoint.x); SERIAL_OUT.print(" , "); SERIAL_OUT.println(waypoint.y); wpw_count++; while(mode == WP_MODE) get_mode(); return ; }
void RadioMMI::updateUi() { if (mUpdate) { mLcd->clear(); if (mIsInTx) { mLcd->print("TX"); } else { mLcd->print("RX"); } printFreq(mStore.freq); printRit(mStore.rit); EEPROM_writeAnything(0, mStore); mUpdate = false; } }
void altitudeSet() { if(digitalRead(upButtonPin)==LOW) altitude += 10; if(digitalRead(downButtonPin)==LOW) altitude -= 10; if(digitalRead(selectButtonPin) == LOW) EEPROM_writeAnything(0, altitude); lcd.setCursor(0,0); lcd.print("Ustaw wysokosc"); lcd.setCursor(0,1); lcd.print("nad poziomem morza"); lcd.setCursor(0,2); lcd.print(altitude); lcd.setCursor(0, 3); lcd.print("SELECT - zapisz"); }
void import_waypoints(){ eeprom_clear(); wpw_count = 1; //resets the counter to import correctly WAYPOINTS_STRING //edit this in header file to change waypoints for(int i=0; i < WAYPOINT_COUNT; i++){ waypoint.x = float(excel_waypoints[i][0]); waypoint.y = float(excel_waypoints[i][1]); EEPROM_writeAnything(wpw_count*WP_SIZE, waypoint); wpw_count++; } wpw_count = 1; //resets the couter for autonomous mode display_waypoints(); SERIAL_OUT.println("ALL POINTS IMPORTED"); SERIAL_OUT.println(); return ; }
void SetBlkPage::ProcessEvent(HmiNavigation::KeyBoardEventList event) { if((event == HmiNavigation::eKbShortUp || event == HmiNavigation::eKbRepeatUp)&& configuration.BlkPwmValue < 100) { configuration.BlkPwmValue++; analogWrite(BlkPwmPin,map(configuration.BlkPwmValue,100,0,0,255)); this->EnterMillisValue = millis(); } else if((event == HmiNavigation::eKbShortDown || event == HmiNavigation::eKbRepeatDown) && configuration.BlkPwmValue > 0) { configuration.BlkPwmValue--; analogWrite(BlkPwmPin,map(configuration.BlkPwmValue,100,0,0,255)); this->EnterMillisValue = millis(); } if(event == HmiNavigation::eKbShortEnter) { EEPROM_writeAnything(0, configuration); Navigation.ShowPage(HmiNavigation::eMainPage); } }
void reset_waypoints(){ /* NOTE THAT WHEN USING THIS FUNCTION, THERE MUST BE AT LEAST 1 WAYPOINT THAT IS NOT 0,0 OR ELSE THE CAR WILL NOT SET WAYPOINTS CORRECTLY AFTER THAT*/ eeprom_clear(); wpw_count = 1; //resets the counter to import correctly int excel_waypoints[19][2] = {{0,1000}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}, {0,0}}; for(int i=0; i < WAYPOINT_COUNT; i++){ waypoint.x = float(excel_waypoints[i][0]); waypoint.y = float(excel_waypoints[i][1]); EEPROM_writeAnything(wpw_count*WP_SIZE, waypoint); wpw_count++; } wpw_count = 1; //resets the couter for autonomous mode display_waypoints(); SERIAL_OUT.println("ALL POINTS IMPORTED"); SERIAL_OUT.println(); return; }
void saveSettingsToEEPROM( ) { //have to dereference SETTINGS because that's what the macro expects EEPROM_writeAnything(EEPROM_SETTINGS_ADDRESS, *SETTINGS); }
void geocacheMenu(void) { int pressedKey = mySwitch.checkKeypad(); switch (menuState) { case MENU0: tft.fillScreen(ST7735_BLACK); setCursorTFT(0,0); tft.print(menuHeader); setCursorTFT(1,0); tft.setTextColor(ST7735_WHITE,ST7735_BLUE); tft.print(monGPSLocn); setCursorTFT(2,0); tft.setTextColor(ST7735_WHITE,ST7735_BLACK); tft.print(monGPSClk); setCursorTFT(3,0); tft.print(downldWays); setCursorTFT(4,0); tft.print(goToWaypts); setCursorTFT(5,0); tft.print(setActWays); setCursorTFT(6,0); tft.print(showWaypts); menuState = MENU0B; break; case MENU0B: if (pressedKey != NOKEY) { if ((pressedKey == SELECT) || (pressedKey == RIGHT)) { tft.fillScreen(ST7735_BLACK); setCursorTFT(0,0); tft.setTextColor(ST7735_WHITE,ST7735_BLUE); tft.print(monGPSLocn); tft.setTextColor(ST7735_WHITE,ST7735_BLACK); clearLine(1); clearLine(2); clearLine(3); clearLine(4); clearLine(5); clearLine(6); menuState = MENU0C; } else if (pressedKey == DOWN) menuState = MENU1; } break; case MENU0C: if (pressedKey != NOKEY) menuState = MENU0; readGPS(); break; case MENU1: tft.fillScreen(ST7735_BLACK); setCursorTFT(0,0); tft.print(menuHeader); setCursorTFT(1,0); tft.print(monGPSLocn); setCursorTFT(2,0); tft.setTextColor(ST7735_WHITE,ST7735_BLUE); tft.print(monGPSClk); tft.setTextColor(ST7735_WHITE,ST7735_BLACK); setCursorTFT(3,0); tft.print(downldWays); setCursorTFT(4,0); tft.print(goToWaypts); setCursorTFT(5,0); tft.print(setActWays); setCursorTFT(6,0); tft.print(showWaypts); menuState = MENU1B; break; case MENU1B: if (pressedKey != NOKEY) { if ((pressedKey == SELECT) || (pressedKey == RIGHT)) { clearLine(0); tft.setTextColor(ST7735_WHITE,ST7735_BLUE); tft.print(monGPSClk); tft.setTextColor(ST7735_WHITE,ST7735_BLACK); clearLine(1); clearLine(2); clearLine(3); clearLine(4); clearLine(5); clearLine(6); menuState = MENU1C; } else if (pressedKey == UP) menuState = MENU0; else if (pressedKey == DOWN) menuState = MENU2; } break; case MENU1C: if (pressedKey != NOKEY) { tft.fillScreen(ST7735_BLACK); menuState = MENU1; } GPSClock(); break; case MENU2: tft.fillScreen(ST7735_BLACK); setCursorTFT(0,0); tft.print(menuHeader); setCursorTFT(1,0); tft.print(monGPSLocn); setCursorTFT(2,0); tft.print(monGPSClk); setCursorTFT(3,0); tft.setTextColor(ST7735_WHITE,ST7735_BLUE); tft.print(downldWays); tft.setTextColor(ST7735_WHITE,ST7735_BLACK); setCursorTFT(4,0); tft.print(goToWaypts); setCursorTFT(5,0); tft.print(setActWays); setCursorTFT(6,0); tft.print(showWaypts); menuState = MENU2B; break; case MENU2B: { int charIn; if (pressedKey != NOKEY) { if ((pressedKey == SELECT) || (pressedKey == RIGHT)) { rxCount = 0; clearLine(2); clearLine(3); clearLine(4); clearLine(5); clearLine(6); clearLine(1); tft.setTextColor(ST7735_WHITE,ST7735_BLUE); tft.print(downldWays); tft.setTextColor(ST7735_WHITE,ST7735_BLACK); setCursorTFT(2,0); menuState = MENU2C; while (Serial.available()) // flush the serial read port charIn = Serial.read(); Serial.println("<DL>"); // signals host that it's time to load waypoints } else if (pressedKey == UP) menuState = MENU1; else if (pressedKey == DOWN) menuState = MENU3; } } break; case MENU2C: { int charIn; int errorCode; if (Serial.available()) { charIn = Serial.read(); if (charIn == '\n') { tft.print("."); rxBuffer[rxCount] = 0; errorCode = parseRxBuffer(); if (errorCode == -1) { clearLine(2); tft.print("Error: Missing equal"); } else if (errorCode == -2) { clearLine(2); tft.print("Error: Bad waypt num"); } rxCount = 0; Serial.write('A'); if ((rxBuffer[0] == '1') && (rxBuffer[1]=='9')) { clearLine(3); tft.print("Download Completed "); EEPROM_writeAnything(0, myStoreVals); Serial.println("</SERIN>"); // signals host that it's time to load waypoints delay(2000); // 2 second message menuState = MENU2; } } else { rxBuffer[rxCount++] = charIn; } } if (pressedKey == UP) { Serial.println("</DL>"); // signals host that it's time to load waypoints clearLine(2); tft.print("Download Terminated "); delay(2000); // 2 second message menuState = MENU2; } } break; case MENU3: tft.fillScreen(ST7735_BLACK); setCursorTFT(0,0); tft.print(menuHeader); setCursorTFT(1,0); tft.print(monGPSLocn); setCursorTFT(2,0); tft.print(monGPSClk); setCursorTFT(3,0); tft.print(downldWays); setCursorTFT(4,0); tft.setTextColor(ST7735_WHITE,ST7735_BLUE); tft.print(goToWaypts); tft.setTextColor(ST7735_WHITE,ST7735_BLACK); setCursorTFT(5,0); tft.print(setActWays); setCursorTFT(6,0); tft.print(showWaypts); menuState = MENU3B; break; case MENU3B: if (pressedKey != NOKEY) { if ((pressedKey == SELECT) || (pressedKey == RIGHT)) { quietReadGPS(); delay(500); menuState = MENU3C; } else if (pressedKey == UP) menuState = MENU2; else if (pressedKey == DOWN) menuState = MENU4; } break; case MENU3C: tft.fillScreen(ST7735_BLACK); tft.drawCircle(64,110,45,ST7735_WHITE); setCursorTFT(0,0); tft.print(menuHeader); setCursorTFT(1,0); tft.print("Going to Waypoint "); setCursorTFT(1,18); tft.print(currentWayPoint, DEC); setCursorTFT(2,0); tft.print("Bearing ="); setCursorTFT(3,0); tft.print("Distance ="); setCursorTFT(4,0); tft.print("Direction ="); setCursorTFT(5,0); tft.print("Satellites ="); quietReadGPS(); setCursorTFT(2,10); tft.print(" "); setCursorTFT(2,10); bearing = calc_bearing(fLat2,fLon2,myStoreVals.lats[currentWayPoint],myStoreVals.lons[currentWayPoint]); tft.print(bearing); lastLat = fLat2; setCursorTFT(3,11); tft.print(" "); setCursorTFT(3,11); tft.print(calc_dist(fLat2,fLon2,myStoreVals.lats[currentWayPoint],myStoreVals.lons[currentWayPoint])); lastLon = fLon2; setCursorTFT(4,12); tft.print(GPS.angle-bearing); lastAngle = GPS.angle; lastBearing = bearing; setCursorTFT(5,13); tft.print(GPS.satellites); lastSats = GPS.satellites; menuState = MENU3D; break; case MENU3D: { if (pressedKey != NOKEY) { menuState = MENU3; break; } if (quietReadGPS() != 0) { break; } float distCalc = calc_dist(fLat2,fLon2,myStoreVals.lats[currentWayPoint],myStoreVals.lons[currentWayPoint]); bearing = calc_bearing(fLat2,fLon2,myStoreVals.lats[currentWayPoint],myStoreVals.lons[currentWayPoint]); if ((fLat2 != lastLat) || (fLon2 != lastLon)) { setCursorTFT(2,10); tft.print(" "); setCursorTFT(2,10); tft.print(bearing); setCursorTFT(3,11); tft.print(" "); setCursorTFT(3,11); tft.print(distCalc); lastLat = fLat2; lastLon = fLon2; } if ((GPS.angle != lastAngle) || (bearing != lastBearing)) { setCursorTFT(4,12); tft.print(" "); setCursorTFT(4,12); tft.print(GPS.angle-bearing); drawVector(GPS.angle-bearing); lastAngle = GPS.angle; lastBearing = bearing; } if (lastSats != GPS.satellites) { setCursorTFT(5,13); tft.print(GPS.satellites); tft.print(" "); } } break; case MENU4: tft.fillScreen(ST7735_BLACK); setCursorTFT(0,0); tft.print(menuHeader); setCursorTFT(1,0); tft.print(monGPSLocn); setCursorTFT(2,0); tft.print(monGPSClk); setCursorTFT(3,0); tft.print(downldWays); setCursorTFT(4,0); tft.print(goToWaypts); setCursorTFT(5,0); tft.setTextColor(ST7735_WHITE,ST7735_BLUE); tft.print(setActWays); tft.setTextColor(ST7735_WHITE,ST7735_BLACK); setCursorTFT(6,0); tft.print(showWaypts); menuState = MENU4B; break; case MENU4B: if (pressedKey != NOKEY) { if ((pressedKey == SELECT) || (pressedKey == RIGHT)) { tft.fillScreen(ST7735_BLACK); setCursorTFT(0,0); tft.setTextColor(ST7735_WHITE,ST7735_BLUE); tft.print(setActWays); tft.setTextColor(ST7735_WHITE,ST7735_BLACK); setCursorTFT(1,0); tft.print(currentWayPoint, DEC); menuState = MENU4C; } else if (pressedKey == UP) { menuState = MENU3; } else if (pressedKey == DOWN) { menuState = MENU5; } } break; case MENU4C: { if (pressedKey != NOKEY) { switch(pressedKey) { case SELECT: myStoreVals.myCurrentWayPoint = currentWayPoint; EEPROM_writeAnything(0, myStoreVals); menuState = MENU4; break; case UP: if (currentWayPoint < 19) currentWayPoint++; delay(250); break; case DOWN: if (currentWayPoint > 0) currentWayPoint--; delay(250); break; } clearLine(1); tft.print(currentWayPoint, DEC); } } break; case MENU5: tft.fillScreen(ST7735_BLACK); setCursorTFT(0,0); tft.print(menuHeader); setCursorTFT(1,0); tft.print(monGPSLocn); setCursorTFT(2,0); tft.print(monGPSClk); setCursorTFT(3,0); tft.print(downldWays); setCursorTFT(4,0); tft.print(goToWaypts); setCursorTFT(5,0); tft.print(setActWays); setCursorTFT(6,0); tft.setTextColor(ST7735_WHITE,ST7735_BLUE); tft.print(showWaypts); tft.setTextColor(ST7735_WHITE,ST7735_BLACK); menuState = MENU5B; break; case MENU5B: if (pressedKey != NOKEY) { if ((pressedKey == SELECT) || (pressedKey == RIGHT)) { tft.fillScreen(ST7735_BLACK); setCursorTFT(0,0); tft.setTextColor(ST7735_WHITE,ST7735_BLUE); tft.print(showWaypts); tft.setTextColor(ST7735_WHITE,ST7735_BLACK); for (int row = 0; row < 15; row++) { setCursorTFT(row+1,0); tft.print(row); tft.print(","); tft.print(myStoreVals.lats[row],4); tft.print(","); tft.print(myStoreVals.lons[row],4); } menuState = MENU5C; } else if (pressedKey == UP) { menuState = MENU4; } } break; case MENU5C: { if (pressedKey != NOKEY) { switch(pressedKey) { case SELECT: case UP: tft.fillScreen(ST7735_BLACK); menuState = MENU5; break; } } break; } } }
void FreeBoardModel::saveConfig() { //write out a current version EEPROM_writeAnything(0, version); //write data EEPROM_writeAnything(EEPROM_VER, config); }
void EEPROM_StoreSettings() { unsigned long ul_help = 20000; unsigned int ui_help = 0; char ver[4]= "000"; int i=EEPROM_OFFSET; EEPROM_writeAnything(i,ver); // invalidate data first EEPROM_writeAnything(i,axis_steps_per_unit); EEPROM_writeAnything(i,max_feedrate); EEPROM_writeAnything(i,max_acceleration_units_per_sq_second); EEPROM_writeAnything(i,move_acceleration); EEPROM_writeAnything(i,retract_acceleration); EEPROM_writeAnything(i,minimumfeedrate); EEPROM_writeAnything(i,mintravelfeedrate); EEPROM_writeAnything(i,ul_help); //Min Segment Time, not used yet EEPROM_writeAnything(i,max_xy_jerk); EEPROM_writeAnything(i,max_z_jerk); //PID Settings, not used yet --> placeholder ui_help = 2560; EEPROM_writeAnything(i,ui_help); //Kp ui_help = 64; EEPROM_writeAnything(i,ui_help); //Ki ui_help = 4096; EEPROM_writeAnything(i,ui_help); //Kd char ver2[4]=EEPROM_VERSION; i=EEPROM_OFFSET; EEPROM_writeAnything(i,ver2); // validate data showString(PSTR("Settings Stored\r\n")); }
void SabreController::writeInputConfiguration(uint8_t input) { int location = (input) * sizeof(Config[input]); EEPROM_writeAnything(location, Config[input]); // write the input configuration to the EEPROM }
// write all changed main menu settings to the EEPROM void SabreController::writeMainMenuSettings() { EEPROM_writeAnything(EEPROM_MENU_SETTINGS, this->MainMenuSettings); }
//Writes the Keys Array to the EEPROM void Keychain::WriteNewKeychain() { EEPROM_writeAnything(KEYCHAIN_EEPROM_START_ADDRESS, Keys); }
void manageROM::writeConfiguration(void) { EEPROM_writeAnything(0, configuration); }
void saveUserStringToEEPROM( ) { EEPROM_writeAnything(EEPROM_USERSTRING_ADDRESS, UserString); }
void saveSettings() { (void) EEPROM_writeAnything(4, settings); }