void gui_layouts_action(uint8_t index) { switch(index) { case(0): gui_switch_task(GUI_SET_WIDGETS); break; case(1): gui_switch_task(GUI_SET_LAYOUT); break; case(2): gui_value_conf_P(PSTR("Pages count"), GUI_VAL_NUMBER, PSTR("%1.0f"), config.gui.number_of_pages, 1, MAX_NUMBER_OF_PAGES, 1, gui_set_layouts_pages_cb); gui_switch_task(GUI_SET_VAL); break; case(3): config.gui.silent ^= (1 << active_page); eeprom_busy_wait(); eeprom_update_byte(&config_ee.gui.silent, config.gui.silent); break; case(4): config.gui.hide_label ^= (1 << active_page); eeprom_busy_wait(); eeprom_update_byte(&config_ee.gui.hide_label, config.gui.hide_label); break; } }
void gui_set_logger_action(uint8_t index) { switch(index) { case(0): config.logger.enabled = !config.logger.enabled; eeprom_busy_wait(); eeprom_update_byte(&config_ee.logger.enabled, config.logger.enabled); break; case(1): if (fc.logger_state == FLIGHT_LAND) { gui_showmessage_P(PSTR("Cannot change\nin flight!")); return; } config.logger.format = (config.logger.format + 1) % NUMBER_OF_FORMATS; eeprom_busy_wait(); eeprom_update_byte(&config_ee.logger.format, config.logger.format); break; case(2): gui_switch_task(GUI_SET_AUTOSTART); break; } }
static bool rfReceivePacket(NWK_DataInd_t *ind) { // First figure out what kind of packet this is, and then call the appropreate function. switch ((packetType_t) (ind->data[0])) { case bacon: processBaconPacket(ind); break; case connectionAck: if(processConnectionAck(ind)) { ui_baseStationConnected(); eeprom_update_block(&(baseStationList[connectedBaseStation]), (void*)27, sizeof(struct baseStation)); eeprom_update_byte((uint8_t*)29, 1); // Force the RSSI of the connected base station to 1 without modifying value in ram. eeprom_update_byte((uint8_t*)26, 0xFF); } break; case dataRequest: if (ind->size != sizeof(dataRequestPacket_t)) break; memcpy(&datRequest, ind->data, sizeof(dataRequestPacket_t)); receivedDataRequest = true; return false; break; case dataAck: handleDataAck(ind); break; case coldStart: receivedColdStart = true; break; default: break; } return true; }
void gui_set_bluetooth_action(uint8_t index) { switch (index) { case(1): config.system.use_bt = !config.system.use_bt; eeprom_busy_wait(); eeprom_update_byte(&config_ee.system.use_bt, config.system.use_bt); if (config.system.use_bt) bt_module_init(); else bt_module_deinit(); break; case(2): config.system.protocol = (config.system.protocol + 1) % NUMBER_OF_PROTOCOLS; eeprom_busy_wait(); eeprom_update_byte(&config_ee.system.protocol, config.system.protocol); break; case(3): config.system.forward_gps = !config.system.forward_gps; eeprom_busy_wait(); eeprom_update_byte(&config_ee.system.forward_gps, config.system.forward_gps); break; } }
void gui_set_advanced_action(uint8_t index) { switch(index) { case(0): config.connectivity.usb_mode = !config.connectivity.usb_mode; eeprom_busy_wait(); eeprom_update_byte(&config_ee.connectivity.usb_mode, config.connectivity.usb_mode); break; case(1): config.connectivity.uart_function = (config.connectivity.uart_function + 1) % NUMBER_OF_UART_FORWARD; eeprom_busy_wait(); eeprom_update_byte(&config_ee.connectivity.uart_function, config.connectivity.uart_function); uart_stop(); uart_init(); break; case(2): if (!storage_card_in()) { gui_showmessage_P(PSTR("No SD card!")); return; } gui_dialog_set_P(PSTR("Warning"), PSTR("This will erase\nall data from SD\ncard! Continue?"), GUI_STYLE_YESNO, gui_set_advanced_format_cb); gui_switch_task(GUI_DIALOG); break; case(3): gui_switch_task(GUI_SET_CALIB); break; } }
void gui_set_autostart_action(uint8_t index) { switch(index) { case(1): gui_value_conf_P(PSTR("Start threshold"), GUI_VAL_NUMBER_DISABLE, PSTR("+/-%0.0fm"), config.autostart.start_sensititvity, 0, 100, 1, gui_set_autostart_start_threshold_cb); gui_switch_task(GUI_SET_VAL); break; case(2): gui_value_conf_P(PSTR("Land threshold"), GUI_VAL_NUMBER_DISABLE, PSTR("+/-%0.0fm"), config.autostart.land_sensititvity, 0, 100, 1, gui_set_autostart_land_threshold_cb); gui_switch_task(GUI_SET_VAL); break; case(3): gui_value_conf_P(PSTR("Timeout"), GUI_VAL_NUMBER, PSTR("%0.0f sec"), config.autostart.timeout, 5, 240, 1, gui_set_autostart_timeout_cb); gui_switch_task(GUI_SET_VAL); break; case(4): config.autostart.flags ^= AUTOSTART_SUPRESS_AUDIO; eeprom_busy_wait(); eeprom_update_byte(&config_ee.autostart.flags, config.autostart.flags); break; case(5): config.autostart.flags ^= AUTOSTART_ALWAYS_ENABLED; eeprom_busy_wait(); eeprom_update_byte(&config_ee.autostart.flags, config.autostart.flags); break; } }
void SetUpNewEEPROM() { eeprom_update_block(sig, (void*)(EEPROM_SIG_START), EEPROM_SIG_LENGTH); eeprom_update_byte((uint8_t*)EEPROM_VERSION_START, DEVICE_VERSION_MAJOR); eeprom_update_byte((uint8_t*)EEPROM_VERSION_START + 1, DEVICE_VERSION_MINOR); eeprom_update_block((const void*)&webUsbDescriptorStringSerialNumber[1], (void*)EEPROM_SERIAL_START, EEPROM_SERIAL_LENGTH); }
void HalRgbLed::saveTorch(short red, short green, short blue) { eeprom_update_byte((uint8_t *)8127, red); eeprom_update_byte((uint8_t *)8128, green); eeprom_update_byte((uint8_t *)8129, blue); torchRedValue = red; torchGreenValue = green; torchBlueValue = blue; }
void reset () { eeprom_update_byte (ADC_BATTERY_EEPROM_CURRENT_SENSOR, ADC_BATTERY_DEFAULT_CURRENT_SENSOR); eeprom_update_float (ADC_BATTERY_EEPROM_VOLTAGE_MULTIPLIER, ADC_BATTERY_DEFAULT_VOLTAGE_MULTIPLIER); eeprom_update_float (ADC_BATTERY_EEPROM_CURRENT_MULTIPLIER, ADC_BATTERY_DEFAULT_CURRENT_MULTIPLIER); eeprom_update_word (ADC_BATTERY_EEPROM_UPDATE_INTERVAL, ADC_BATTERY_DEFAULT_UPDATE_INTERVAL); eeprom_update_byte (ADC_BATTERY_EEPROM_VOLTAGE_CHANNEL, ADC_BATTERY_DEFAULT_VOLTAGE_CHANNEL); eeprom_update_byte (ADC_BATTERY_EEPROM_CURRENT_CHANNEL, ADC_BATTERY_DEFAULT_CURRENT_CHANNEL); }
void reset () { eeprom_update_byte (OSD_EEPROM_SWITCH, OSD_EEPROM_SWITCH_DEFAULT); eeprom_update_byte (OSD_EEPROM_SWITCH_RAW_CHANNEL, OSD_EEPROM_SWITCH_RAW_CHANNEL_DEFAULT); eeprom_update_byte (OSD_EEPROM_SCREENS, OSD_MAX_SCREENS); eeprom_update_word (OSD_EEPROM_CHANNEL_MIN, OSD_CHANNEL_MIN); eeprom_update_word (OSD_EEPROM_CHANNEL_MAX, OSD_CHANNEL_MAX); screen::settings::reset (); }
//some more initialization of EEPROM void increase_day_count_eeprom(){ curr_day = eeprom_read_byte (& NonVolatileDayCount); curr_day++; if(curr_day>5){ curr_day = 1; } if(write_enable_update_date_count_eeprom){ eeprom_update_byte ((uint8_t*) (&NonVolatileDayCount), curr_day); } for(int i=0;i<MAX_PEOPLE;i++){ eeprom_update_byte ((uint8_t*) (&NonVolatileIsPresent[curr_day][i]), 0); } }
void enter_bootloader(uint8_t nad, uint8_t function) { // make sure the watchdog doesn't catch us while we're updating the EEPROM wdt_reset(); // write magic to the EEPROM to cause us to wait in the bootloader eeprom_update_byte((uint8_t *)kConfigNodeAddress, nad); eeprom_update_byte((uint8_t *)kConfigFunction, function); eeprom_update_word((uint16_t *)kConfigMagic, kBLMagic); // operation_magic::kEnterBootloader reset(); }
void Qtwo__init (void) { if (eeprom_read_byte(&modeAutoColor_EEPROM) == TRUE) { modeAutoColor = TRUE; } else { /* automatic color change */ modeAutoColor = FALSE; eeprom_update_byte(&modeAutoColor_EEPROM, modeAutoColor); } if (eeprom_read_byte(¤tColor_EEPROM) < QTWO_COLOR_NB) { currentColor = eeprom_read_byte(¤tColor_EEPROM); } else { currentColor = 0; eeprom_update_byte(¤tColor_EEPROM, currentColor); } /* brightness level */ if ((eeprom_read_byte(¤tBrightnessSetting_EEPROM)) == QTWO_BRIGHTNESS_HIGH) { currentBrightnessSetting = QTWO_BRIGHTNESS_HIGH; currentBrightnessTable = brightnessLevels_high; } else { currentBrightnessSetting = QTWO_BRIGHTNESS_LOW; currentBrightnessTable = brightnessLevels; eeprom_update_byte(¤tBrightnessSetting_EEPROM, currentBrightnessSetting); } if ((eeprom_read_byte(&selectedLang_EEPROM)) < QTWO_LANG_NB) { selectedLang = eeprom_read_byte(&selectedLang_EEPROM); } else { selectedLang = QTWO_LANG_DE_SUED; eeprom_update_byte(&selectedLang_EEPROM, selectedLang); } /* other states initialized in Qtwo__modeTransition() */ }
static void write_byte(cfg_addr_t pos, uint8_t b) { DBG_C(' '); DBG_X(pos); DBG_C('='); DBG_X(b); eeprom_update_byte((uint8_t *)EEPROM_POS + pos, b); }
void gui_page_power_off() { gui_splash_set_mode(SPLASH_OFF); gui_switch_task(GUI_SPLASH); eeprom_busy_wait(); eeprom_update_byte(&config.gui.last_page, active_page); }
void gui_set_display_brightness_timeout_cb(float val) { gui_switch_task(GUI_SET_DISPLAY); eeprom_busy_wait(); lcd_brightness_timeout = val; eeprom_update_byte(&config.gui.brightness_timeout, lcd_brightness_timeout); }
void keymap_keycode_save(uint8_t layer, uint8_t row, uint8_t column, uint16_t keycode) { void *address = keymap_key_to_eeprom_address(layer, row, column); // Big endian, so we can read/write EEPROM directly from host if we want eeprom_update_byte(address, (uint8_t)(keycode >> 8)); eeprom_update_byte(address+1, (uint8_t)(keycode & 0xFF)); }
void putValue(void* aAdr, uint8_t aPType, int32_t* aValue) { union { void* adr; uint8_t* u8Adr; uint16_t* u16Adr; // uint32_t* u32Adr; } a; a.adr = aAdr; if (ISEEADR(aPType)) { if (IS8BIT(aPType)) eeprom_update_byte(aAdr, ISSIGNED(aPType) ? (int8_t) *aValue : (uint8_t) *aValue); else if(IS16BIT(aPType)) eeprom_update_word(aAdr, ISSIGNED(aPType) ? (int16_t) *aValue : (uint16_t) *aValue); #ifdef WITH_EE32VALUES else if(IS32BIT(aPType)) eeprom_update_dword(aAdr, ISSIGNED(aPType) ? *aValue : (uint32_t) *aValue); #endif } else if (ISRAMADR(aPType)) { if (IS8BIT(aPType)) *a.u8Adr = ISSIGNED(aPType) ? (int8_t) *aValue : (uint8_t) *aValue; else if(IS16BIT(aPType)) *a.u16Adr = ISSIGNED(aPType) ? (int16_t) *aValue : (uint32_t) *aValue; #ifdef WITH_EE32VALUES else if(IS32BIT(aPType)) *a.u32Adr = ISSIGNED(aPType) ? *aValue : (uint32_t) *aValue; #endif } feedback(1, BLINK_MEDIUM, WITH_LED1); } // getValue
void hadUsbReset(void) { cli(); // usbMeasureFrameLength() counts CPU cycles, so disable interrupts. calibrateOscillator(); sei(); eeprom_update_byte(&eeCalibrationMemory, OSCCAL); /* store the calibrated value in EEPROM */ }
int main(void) { initUSART(); char ramString[STRING_LEN]; uint8_t counter; while (1) { printString("\r\n------------------\r\n"); eeprom_read_block(ramString, eepromString, STRING_LEN); printString(ramString); printString("\r\nThe counter reads: "); counter = eeprom_read_byte(&eepromCounter); printByte(counter); printString("\r\nMy uint16_t value is: "); printWord(eeprom_read_word(&eepromWord)); printString("\r\n Enter a new introduction string below:\r\n"); readString(ramString, STRING_LEN); eeprom_update_block(ramString, eepromString, STRING_LEN); counter++; eeprom_update_byte(&eepromCounter, counter); } return (0); }
/* Sprawdzanie, czy wylosowano wszystkie liczby. Jeśli tak, czyszczenie pamięci EEPROM */ void zeruj() { uint8_t wylosowana = 1; //flaga int i; for (i = 0; i < iloscUczniow; i++) //sprawdzanie, czy istnieje chociaż jedna niewylosowana wartość { uint8_t odp = eeprom_read_byte((uint8_t *) i); if (odp == 0) { wylosowana = 0; break; } } if (wylosowana == 1) { for (i = 0; i < iloscUczniow; i++) //trzeba je oznaczyc jako niewylosowane { eeprom_update_byte((uint8_t *) i, 0); eeprom_busy_wait(); } } }
void gui_set_altimeter_stop() { if (set_alt_index == 0) { config.altitude.alt1_flags = set_alt_flags; eeprom_busy_wait(); eeprom_update_byte(&config_ee.altitude.alt1_flags, set_alt_flags); } else { config.altitude.altimeter[set_alt_index - 1].flags = set_alt_flags; eeprom_busy_wait(); eeprom_update_byte(&config_ee.altitude.altimeter[set_alt_index - 1].flags, set_alt_flags); } }
void logger_init() { log_fil = new FIL; fc.logger_state = LOGGER_IDLE; uint8_t sec, min, hour, day, wday, month; uint16_t year; uint32_t today; datetime_from_epoch(time_get_local(), &sec, &min, &hour, &day, &wday, &month, &year); today = datetime_to_epoch(0, 0, 0, day, month, year); eeprom_busy_wait(); eeprom_read_block((void *)&logger_flight_day, &config_ro.flight_date, sizeof(logger_flight_day)); logger_flight_number = eeprom_read_byte(&config_ro.flight_number); if (logger_flight_day != today) { logger_flight_number = 0; logger_flight_day = today; eeprom_busy_wait(); eeprom_update_block((void *)&logger_flight_day, &config_ro.flight_date, sizeof(logger_flight_day)); eeprom_update_byte(&config_ro.flight_number, logger_flight_number); } DEBUG("date is: "); print_datetime(today); DEBUG("flight number is: %d\n", logger_flight_number); }
void gui_set_system_action(uint8_t index) { switch(index) { case(0): gui_switch_task(GUI_SET_TIME); break; case(1): gui_switch_task(GUI_SET_DISPLAY); break; case(2): gui_switch_task(GUI_SET_AUDIO); break; case(3): config.connectivity.usb_mode = !config.connectivity.usb_mode; eeprom_busy_wait(); eeprom_update_byte(&config_ee.connectivity.usb_mode, config.connectivity.usb_mode); break; case(4): gui_value_conf_P(PSTR("Auto power-off"), GUI_VAL_NUMBER_DISABLE, PSTR("%0.0f min"), config.system.auto_power_off, 0, 120, 1, gui_set_system_auto_power_off_cb); gui_switch_task(GUI_SET_VAL); break; case(5): config.connectivity.uart_function = (config.connectivity.uart_function + 1) % NUMBER_OF_UART_FORWARD; eeprom_busy_wait(); eeprom_update_byte(&config_ee.connectivity.uart_function, config.connectivity.uart_function); uart_stop(); uart_init(); break; case(6): if (!storage_card_in()) { gui_showmessage_P(PSTR("No SD card!")); return; } gui_dialog_set_P(PSTR("Warning"), PSTR("This will erase\nall data from SD\ncard! Continue?"), GUI_STYLE_OKCANCEL, gui_set_system_format_cb); gui_switch_task(GUI_DIALOG); break; } }
void gui_set_audio_vol_cb(float val) { gui_switch_task(GUI_SET_AUDIO); eeprom_busy_wait(); uint8_t tmp = val; eeprom_update_byte(&config.audio_profile.volume, tmp); fc.audio_volume = tmp; }
void gui_set_display_brightness_cb(float val) { gui_switch_task(GUI_SET_DISPLAY); eeprom_busy_wait(); lcd_brightness = val; eeprom_update_byte(&config.gui.brightness, lcd_brightness); gui_trigger_backlight(); }
void settings_set_byte(uint8_t key, uint8_t value) { if (key < ByteSettingsKeyCount) { eeprom_update_byte(&eeByteSettings[key], value); change_flags |= SettingsByte; } }
void gui_set_autoset_config_circling_thold_cb(float val) { gui_switch_task(GUI_SET_AUTOSET_CONFIG); config.gui.page_cirlcing_thold = val; eeprom_busy_wait(); eeprom_update_byte(&config_ee.gui.page_cirlcing_thold, config.gui.page_cirlcing_thold); }
void gui_set_display_contrast_cb(float val) { gui_switch_task(GUI_SET_DISPLAY); eeprom_busy_wait(); lcd_contrast = val; eeprom_update_byte(&config.gui.contrast, lcd_contrast); gui_change_disp_cfg(); }
void gui_set_autoset_config_acro_thold_cb(float val) { gui_switch_task(GUI_SET_AUTOSET_CONFIG); config.gui.page_acro_thold = val * 10.0; eeprom_busy_wait(); eeprom_update_byte((uint8_t *)&config_ee.gui.page_acro_thold, config.gui.page_acro_thold); }