void oled_init() { SPI_MasterInit(); DDRB|=(1<<PB0)|(1<<PB1); PORTB&=~(1<<PB0); _delay_ms(50); PORTB|=(1<<PB0); PORTB&=~(1<<PB1); //发送命令 SPI_MasterTransmit(0xae);//--turn off oled panel SPI_MasterTransmit(0x00);//---set low column address SPI_MasterTransmit(0x10);//---set high column address SPI_MasterTransmit(0x40);//--set start line address Set Mapping RAM Display Start Line (0x00~0x3F) SPI_MasterTransmit(0x81);//--set contrast control register SPI_MasterTransmit(0xcf); // Set SEG Output Current Brightness SPI_MasterTransmit(0xa1);//--Set SEG/Column Mapping 0xa0左右反置 0xa1正常 SPI_MasterTransmit(0xc8);//Set COM/Row Scan Direction 0xc0上下反置 0xc8正常 SPI_MasterTransmit(0xa6);//--set normal display SPI_MasterTransmit(0xa8);//--set multiplex ratio(1 to 64) SPI_MasterTransmit(0x3f);//--1/64 duty SPI_MasterTransmit(0xd3);//-set display offset Shift Mapping RAM Counter (0x00~0x3F) SPI_MasterTransmit(0x00);//-not offset SPI_MasterTransmit(0xd5);//--set display clock divide ratio/oscillator frequency SPI_MasterTransmit(0x80);//--set divide ratio, Set Clock as 100 Frames/Sec SPI_MasterTransmit(0xd9);//--set pre-charge period SPI_MasterTransmit(0xf1);//Set Pre-Charge as 15 Clocks & Discharge as 1 Clock SPI_MasterTransmit(0xda);//--set com pins hardware configuration SPI_MasterTransmit(0x12); SPI_MasterTransmit(0xdb);//--set vcomh SPI_MasterTransmit(0x40);//Set VCOM Deselect Level SPI_MasterTransmit(0x20);//-Set Page Addressing Mode (0x00/0x01/0x02) SPI_MasterTransmit(0x02);// SPI_MasterTransmit(0x8d);//--set Charge Pump enable/disable SPI_MasterTransmit(0x14);//--set(0x10) disable SPI_MasterTransmit(0xa4);// Disable Entire Display On (0xa4/0xa5) SPI_MasterTransmit(0xa6);// Disable Inverse Display On (0xa6/a7) SPI_MasterTransmit(0xaf);//--turn on oled panel /* SPI_MasterTransmit(0xAF); SPI_MasterTransmit(0x40); SPI_MasterTransmit(0xA0); SPI_MasterTransmit(0xA6); SPI_MasterTransmit(0xA4); SPI_MasterTransmit(0xA2); SPI_MasterTransmit(0xC8); SPI_MasterTransmit(0x2F); SPI_MasterTransmit(0x24); SPI_MasterTransmit(0x81); SPI_MasterTransmit(0x24); */ oled_clear(); }
// ------------------------------------------------------------ int main(void) { oled_port_prepare(); oled_reset(); oled_init(); oled_clear(); oled_flip_horizontal(0); oled_flip_vertical(0); oled_brightness(0xFF); /* oled_print(0,0,0,"1234567890"); oled_print(1,0,0,"ABCDEFGHIJKLMN"); oled_print(2,0,0,"OPQRSTUVWXYZ"); oled_print(3,0,0,"abcdefghijklmn"); oled_print(4,0,0,"opqrstuvwxyz"); oled_print(6,0,0,"^`_{|}:'<=>?@"); */ /* for(r=0; r<7; r++) // KAZKODEL SUSIGADINA STATIC VAIZDAS!!! { oled_write_cmd(0x10); oled_write_cmd(0x00); oled_write_cmd(0xB0+r); for (i=0;i<128;i++) { oled_write_data(picwilibox[pos++]); } } */ oled_print2(0, 0, "Wilibox"); oled_print2(0, 2, "-------"); oled_print2(0, 4, "1234567890"); oled_print(7,0,0,"123456789012345678901"); read_bit(BUTTON); write_bit(LED2_GRN, 0); oled_close(); return 0; }
int main (int argc, char **argv) { int i, i2, row = 127; char bmp_hdr[54]; unsigned char buff[3]; FILE *file; oled_init(); oled_write_c(0xae); /* Display off */ oled_clear(); file = fopen("/root/splash.bmp", "rb"); fread(&bmp_hdr, 1, 54, file); for (i = 0; i < 128; i++) { for (i2 = 0; i2 < 128; i2++) { fread(&buff, 1, 3, file); frame_buffer[row][i2][0] = buff[2] / 4; frame_buffer[row][i2][1] = buff[1] / 4; frame_buffer[row][i2][2] = buff[0] / 4; } row--; } gui_textbox_t txtLoading; strcpy(txtLoading.text, "Loading..."); txtLoading.x = oled_screenwidth / 2; txtLoading.y = 100; txtLoading.maxwidth = 0; txtLoading.align = 2; txtLoading.mode = 0; txtLoading.color[0] = 17; txtLoading.color[1] = 27; txtLoading.color[2] = 45; gui_textbox_init(&txtLoading); //gui_textbox_draw(&txtLoading); oled_flush(); oled_write_c(0xaf); /* Display on */ return 0; }
void display_highscore_list(uint8_t offset) { // Print text to OLED oled_clear(); oled_goto_line(offset); oled_goto_column(0); oled_print_p(PSTR("Highscore list")); for(int i = 0; i < HIGHSCORE_LENGTH; i++) { oled_goto_line(2+offset+i); oled_goto_column(0); for (int j = 0; j < NAME_LENGTH; j++) { oled_putchar(highscore_list[i].name[j]); } oled_print(" "); oled_print(uint16_to_str(highscore_list[i].score)); } }
// ------------------------------------------------------------ int main(int argc, char *argv[]) { int i; oled_port_prepare(); oled_reset(); oled_init(); oled_clear(); oled_flip_horizontal(0); oled_flip_vertical(0); oled_brightness(0xFF); if (argc < 2) { fprintf(stderr, "Usage: %s \"string1\" \"string2\"..\n", argv[0]); exit(EXIT_FAILURE); } for (i = 1; i < argc; i++) { oled_print2(0, 2 * (i - 1), argv[i]); } oled_close(); exit(EXIT_SUCCESS); }
highscore_element_t enter_initials(uint16_t score) { highscore_element_t new_score; int8_t set_char = 0; uint8_t iter = 0; // Print text to OLED oled_clear(); oled_goto_line(0); oled_goto_column(0); oled_print_p(PSTR("Your score ")); oled_print(uint16_to_str(score)); oled_goto_line(2); oled_goto_column(0); oled_print_p(PSTR("Enter you initials")); oled_goto_line(6); oled_goto_column(0); oled_print_p(PSTR("Press left button when finished")); //Recently obtained score new_score.score = score; //Initial initials new_score.name[0] = 'A'; new_score.name[1] = 'A'; new_score.name[2] = 'A'; //Stay in the enter_initials menu until left slider button is pushed while (!SLIDER_left_button()) { if (JOY_getDirection() == UP) { if (++iter > SET_NAME_DELAY) { iter = 0; //Increment selected initial if (set_char == 0) { new_score.name[0]--; } else if (set_char == 1) { new_score.name[1]--; } else { new_score.name[2]--; } //Check for under-roll if (new_score.name[set_char] < 'A') new_score.name[set_char] = 'Z'; } } else if (JOY_getDirection() == DOWN) { if (++iter > SET_NAME_DELAY) { iter = 0; //Increment selected initial if (set_char == 0) { new_score.name[0]++; } else if (set_char == 1) { new_score.name[1]++; } else { new_score.name[2]++; } //Check for over-roll if (new_score.name[set_char] > 'Z') new_score.name[set_char] = 'A'; } } else if (JOY_getDirection() == LEFT) { if (++iter > SET_NAME_DELAY) { iter = 0; //Change which initial to edit set_char--; // Check for under-roll if (set_char < 0) set_char = NAME_LENGTH-1; } } else if (JOY_getDirection() == RIGHT) { if (++iter > SET_NAME_DELAY) { iter = 0; //Change which initial to edit set_char++; // Check for over-roll if (set_char > NAME_LENGTH-1) set_char = 0; } } //if change, update screen if(iter == 0) { oled_goto_line(3); oled_goto_column(0); for (int i = 0; i < NAME_LENGTH; i++) { if (set_char == i) { oled_putchar_underscore(new_score.name[i]); } else { oled_putchar(new_score.name[i]); } } } _delay_ms(10); } return new_score; }
static rt_err_t ssd1306_init(void) { rt_uint8_t data[2]; ssd1306_gpio_init(); // Turn off panel oled_writeCmd(0xAE); // Set display clock data[0] = 0xD5; data[1] = 0x80; // default oled_writeLongCmd(data, 2); // Set charge pump data[0] = 0x8D; data[1] = 0x14; // enable oled_writeLongCmd(data, 2); // Set pre-charge period data[0] = 0xD9; data[1] = 0xF1; oled_writeLongCmd(data, 2); // Set Vcomh deselect level data[0] = 0xDB; data[1] = 0x30; // 0x83 x Vcc oled_writeLongCmd(data, 2); // Set contrast data[0] = 0x81; data[1] = 0xEF; oled_writeLongCmd(data, 2); // Set memory addressing mode data[0] = 0x20; data[1] = 0x00; // horizontal mode oled_writeLongCmd(data, 2); // Set segment remap oled_writeCmd(0xA1); // colume 127 -> SEG0 // Set normal display oled_writeCmd(0xA6); // Set multiplex ratio data[0] = 0xA8; data[1] = 0x3f; // N = 64, default oled_writeLongCmd(data, 2); // Set COM output scan direction oled_writeCmd(0xC8); // from COM[N-1] to COM0 // Set COM pin data[0] = 0xDA; data[1] = 0x12; // alternative, disable left/right remap, default oled_writeLongCmd(data, 2); // Set display offset data[0] = 0xD3; data[1] = 0x00; // default oled_writeLongCmd(data, 2); // Set low column address // oled_writeCmd(0x00); // default // Set high column address // oled_writeCmd(0x10); // default // Set display start line oled_writeCmd(0x40); // default // Turn on display oled_writeCmd(0xA4); // Turn on panel oled_writeCmd(0xAF); oled_clear(); return RT_EOK; }
// Application Start void main(void) { // Prepare Application; MCC generated code SYSTEM_Initialize(); // Custom Initializations /* * watchdog timer * configured for 131s timeout * */ //WDTCONbits.SWDTEN = 1; // enable watchdog //ClrWdt(); oled_init(); // Dispaly USBDeviceInit(); // usb_device.c. Initializes USB module SFRs and firmware // variables to known states. USBDeviceAttach(); // Interrupts Enabled PEIE = 1; GIE = 1; // Test Hardware moteApp_delayms(300); modemResync(); moteApp_delayms(300); // moteApp_clearCommand(); // moteApp_delayms(100); powerOnStatus = DATAEE_ReadByte(0x00); #if 0 if ( powerOnStatus != 0x55) { test_powerup(); DATAEE_WriteByte(0x00, 0x55); } #endif // Default to USB operationType = USB; // Mode State USBapp_handlerState(USB_STARTUP); // Initial Display Print oled_clear(); oled_putString("Scriptr IoT-X",0,0); oled_putString(" Dev: S1 ",0,1); oled_putString(" build 006 ",0,3); moteApp_delayms(700); // Application Loop while(1) { // Handle USB or Solo Mode switch (operationType) { default: // Invalid while(1); // Hold For Error; break; case USB: USBapp_Handler(); // It is held in here. // USB escaped; Cable is unplugged; Change OPERATION mode. operationType = MOTE; MOTEapp_handlerState(MOTE_STARTUP); // Initial state for startup break; case MOTE: if (moteHandler() == MOTE_SWAP) { // Return to USB Operation operationType = USB; // Mode State USBapp_handlerState(USB_STARTUP); } break; } } }
static MOTE_RUNNING_T moteRunningProcess(bool changeStates, bool selectButton, bool messageReady, bool sleepEvent) { uint8_t readByte = 0; if ((sleepEvent) && (periodicState)) { if (sleepTicker >= PeriodicInSleep) // No Manual Transmission for a time; Do one Auto { // Measure Sensors uint16_t Traw = 0; moteApp_delayms(10); for(uint8_t i = 32; i>0; i--) { light = (light + ADC_GetConversion(Light_channel)) / 2; } moteApp_delayms(10); for(uint8_t i = 32; i>0; i--) { Traw = (Traw + ADC_GetConversion(Temp_channel)) / 2; } temperature = ADC_TempConversion(Traw); // Do Normal Operation sleepTicker = 0; oled_clear(); oled_putString("Issue Perodic TX",0,0); oled_putString("On Port #: ",0,1); oled_putUint8(randomPortNum,10,1); oled_putString("L: T: ",0,2); oled_putUint16(light,3,2); oled_putUint8(temperature,12,2); oled_putString("(NAV) (SEL) ",0,3); // Prepare Buffers and data moteApp_clearBuffers(); randomPortNum = TMR2_ReadTimer(); // Make Sure Port is in allowed Range if (!randomPortNum) randomPortNum = 5; else if (randomPortNum > 223) randomPortNum = randomPortNum - 50; // Prepare DataBuffer for Tx moteApp_add8bToDataBuffer(randomPortNum, 0); dataBuffer[3] = 0x20; moteApp_add16bToDataBuffer(light, 4); moteApp_add8bToDataBuffer(temperature, 9); NOP(); sleepTxOccurances = 0; oled_putString("C",15,1); sendDataCommand("radio tx ", dataBuffer, 12); secTicker = SleepTimeOut - (SleepTimeOut / 3); runningState = runningUplinkTransmit; } else { sleepTicker++; runningState = runningSleep; selectButton = true; } } moteApp_GoToSleep(); // Menu Operation switch(runningState) { default: // Invalid while(1); // Hold for Error break; } return runningState; // no return value needed but we declare one for this function. }
static MOTE_T moteJoiningProcess(bool messageReady, bool switchEvent) { static int ch = 0; bool joiningComplete = false; static int mode = 0; static unsigned char pkt_cnt = 0; static unsigned char float_val = 255; static bool pending_confirm = false; char buf[50]; static int skip_count = 0; /*if (switchEvent) { activeState = moteComFailure; while(!SWITCH_2_PORT); }*/ switch (activeState) { default: // Invalid while(1); // Hold for Error break; case moteStartup: // HACK to block for Espruino //EUSART_TX_TRIS = INPUT; //while (1) {}; //sendCommand("sys reset"); LED_RED_LAT = 0; LED_GREEN_LAT = 0; // flush buffer while (MOTEapp_getModemResponse()); sendCommand("sys get ver"); oled_clear(); oled_putString("get ver",0,0); moteApp_delayms(100); activeState = moteReset; //activeState = moteStartup; break; case moteReset: if ( messageReady ) { if(strncmp(&modemResonseBuffer[2], "2903", 4) == 0) // Check 1st [2] Bytes for RN { sendCommand("mac set devaddr DEAD00A1"); oled_clear(); oled_putString("set devaddr",0,0); moteApp_delayms(80); activeState = moteSetDevaddr; } else { oled_clear(); oled_putString(modemResonseBuffer,0,3); moteApp_delayms(1000); activeState = moteStartup; } } break; case moteSetDevaddr: if ( messageReady ) { if(strcmp(modemResonseBuffer, "ok") == 0) { sendCommand("mac set appskey 2B7E151628AED2A6ABF7158809CF4F3C"); oled_clear(); oled_putString("set appskey",0,0); moteApp_delayms(80); activeState = moteSetAppskey; } else // Retry Command { activeState = moteStartup; } } break; case moteSetAppskey: if ( messageReady ) { if(strcmp(modemResonseBuffer, "ok") == 0) { sendCommand("mac set nwkskey 2B7E151628AED2A6ABF7158809CF4F3C"); oled_clear(); oled_putString("set nwkskey",0,0); moteApp_delayms(80); activeState = moteSetNwkskey; } else // Retry Command { activeState = moteStartup; } } break; case moteSetNwkskey: if ( messageReady ) { if(strcmp(modemResonseBuffer, "ok") == 0) { sendCommand("mac set adr off"); oled_clear(); oled_putString("set adr",0,0); moteApp_delayms(80); activeState = moteSetAdr; } else // Retry Command { activeState = moteStartup; } } break; case moteSetAdr: if ( messageReady ) { if(strcmp(modemResonseBuffer, "ok") == 0) { sendCommand("mac set sync 34"); oled_clear(); oled_putString("set sync",0,0); moteApp_delayms(80); activeState = moteSetSync; } else // Retry Command { activeState = moteStartup; } } break; case moteSetSync: if ( messageReady ) { if(strcmp(modemResonseBuffer, "ok") == 0) { sendCommand("mac set rx2 8 923300000"); oled_clear(); oled_putString("set rx2",0,0); moteApp_delayms(80); ch = 0; // start with channel 0 activeState = moteSetRx2; //activeState = moteSetChStatus; } else // Retry Command { activeState = moteStartup; } } break; case moteSetRx2: if ( messageReady ) { if(strcmp(modemResonseBuffer, "ok") == 0) { // only enable subband #2 sprintf(cmd,"mac set ch status %d %s", ch, (ch>=8 && ch<=15)?"on":"off"); sendCommand(cmd); oled_clear(); oled_putString("set ch",0,0); oled_putString(&cmd[18],0,1); moteApp_delayms(80); ch++; if (ch<72) { activeState = moteSetRx2; } else { activeState = moteSetChStatus; } } else // Retry Command { activeState = moteStartup; } } break; case moteSetChStatus: if ( messageReady ) { if(strcmp(modemResonseBuffer, "ok") == 0) { moteApp_delayms(200); sendCommand("mac join abp"); oled_clear(); oled_putString("join abp",0,0); moteApp_delayms(80); activeState = moteJoinAbp; } else // Retry Command { activeState = moteStartup; } } break; case moteJoinAbp: if ( messageReady ) { if(strcmp(modemResonseBuffer, "ok") == 0) { // waiting now for "accepted" oled_clear(); oled_putString("Wait accepted...",0,0); moteApp_delayms(80); activeState = moteWaitAccepted; } else // Retry Command { activeState = moteStartup; } } break; case moteWaitAccepted: if ( messageReady ) { if(strcmp(modemResonseBuffer, "accepted") == 0) { //while (MOTEapp_getModemResponse()); // send initial packet sendCommand("mac tx uncnf 1 00000000"); oled_clear(); oled_putString("ini tx",0,0); moteApp_delayms(150); activeState = moteIniTx; LED_GREEN_LAT = 1; } else // Retry Command { oled_clear(); oled_putString("moteWaitAccepted",0,0); activeState = moteStartup; moteApp_delayms(500); LED_RED_LAT = 1; } } break; case moteIniTx: if ( messageReady ) { if(strcmp(modemResonseBuffer, "ok") == 0) { oled_clear(); oled_putString("wait mac_tx_ok",0,0); moteApp_delayms(3000); activeState = moteWaitIniTxOk; LED_RED_LAT = 1; } else // Retry Command { oled_clear(); oled_putString("moteIniTx",0,0); activeState = moteStartup; moteApp_delayms(500); LED_GREEN_LAT = 0; } } break; case moteWaitIniTxOk: //if ( messageReady ) { //if(strcmp(modemResonseBuffer, "mac_tx_ok") == 0) { LED_RED_LAT = 1; LED_GREEN_LAT = 0; // next we rest for a while oled_clear(); oled_putString("Mode: ",0,0); oled_putString(autoMode?"AUTO ":"MANUAL",6,0); oled_putString("S1 = auto on/off",0,1); oled_putString("S2 = manual send",0,2); moteApp_delayms(80); ch = 0; activeState = moteRest; } /*else if (strcmp(modemResonseBuffer, "") == 0) { // glitch where we get an extra return moteApp_delayms(1); LED_GREEN_LAT = 0; moteApp_delayms(1); LED_GREEN_LAT = 1; moteApp_delayms(1); activeState = moteWaitIniTxOk; } else // Retry Command { oled_clear(); oled_putString("WaitIniTxOk",0,0); oled_putString(modemResonseBuffer,0,2); sprintf(cmd,"buflen=%d",strlen(modemResonseBuffer)); oled_putString(cmd,0,3); activeState = moteStartup; moteApp_delayms(1000); }*/ } break; case moteRest: if (autoMode || manualTrigger) { ch++; } moteApp_delayms(100); /* check buttons */ S1 = SWITCH_1_PORT; // 1 == unpressed, 0 = pressed S2 = SWITCH_2_PORT; if (S1 == 0 && prevS1 == 1) { /* rising edge of switch 1 */ /* alternate mode */ autoMode = !autoMode; oled_putString("Mode: ",0,0); oled_putString(autoMode?"AUTO ":"MANUAL",6,0); } if (S2 == 0 && prevS2 == 1) { /* rising edge of switch 2 */ /* schedule a measurement */ manualTrigger = true; } prevS1 = S1; prevS2 = S2; if (ch>20) { manualTrigger=false; ch = 0; // make a measurement uint16_t Traw = 0; moteApp_delayms(10); for(uint8_t i = 32; i>0; i--) { light = (light + ADC_GetConversion(Light_channel)) / 2; } moteApp_delayms(10); for(uint8_t i = 32; i>0; i--) { Traw = (Traw + ADC_GetConversion(Temp_channel)) / 2; } temperature = ADC_TempConversion(Traw); m10SecTicker = 0; pkts++; // display measurement oled_clear(); oled_putString("Mode: ",0,0); oled_putString(autoMode?"AUTO ":"MANUAL",6,0); oled_putString("Light:",0,1); oled_putString("Temp :",0,2); oled_putString("C",12,2); oled_putUint16(light,6,1); oled_putUint16(temperature,6,2); oled_putString("Pkts|:",0,3); oled_putUint16(pkts,6,3); sprintf(cmd,"mac tx uncnf 1 %04X%04X", pkts,dr); sendCommand(cmd); activeState = moteTxUncnf; } break; case moteTxUncnf: //if ( messageReady ) { //if(strcmp(modemResonseBuffer, "ok") == 0) { oled_putString("Pkts/:",0,3); oled_putUint16(pkts,6,3); moteApp_delayms(80); activeState = moteTxWait; } /*else { oled_clear(); oled_putString("TxUncnf",0,0); activeState = moteStartup; moteApp_delayms(500); }*/ } break; case moteTxWait: if ( messageReady ) { if(strcmp(modemResonseBuffer, "mac_tx_ok") == 0) { dr = (dr + 1) % 4; // 0-3 sprintf(cmd,"mac set dr %d",dr); sendCommand(cmd); oled_putString("Pkts-:",0,3); oled_putUint16(pkts,6,3); activeState = moteNextDr; } } break; case moteNextDr: if ( messageReady ) { if(strcmp(modemResonseBuffer, "ok") == 0) { //oled_putString("Pkts-:",0,3); //oled_putUint16(pkts,6,3); activeState = moteRest; } } break; case moteDone: joiningComplete = true; moteApp_delayms(80); break; case moteComFailure: DATAEE_WriteByte(0x00, 0x00); while((!SWITCH_1_PORT) && (!SWITCH_2_PORT)); moteApp_delayms(40); RESET(); // Do Nothing; Wait for USB; Hold for Display break; } return joiningComplete; }
MOTE_MODE_T moteHandler(void) { bool gotoSleep = false; bool gotoNextState = false; bool s2Button = false; bool readMessage = false; buttonStates_t buttonPress = Released; // Check USB connection state if (USB_DET_PORT) moteState = MOTE_SWAP; // Get Timer Ticks if ( appTimer.mSecTick ) { // Clear Flags for next task TMRapp_ClearBitFlags(); // Execute Task TMRapp_Handler(); MOTEapp_TimerBasedTask(appTimer); } // Handle button press events for menu navigation buttonPress = service_pushbutton(); if (buttonPress == ShortPress1) { secTicker = 0; gotoNextState = true; // Button Event has occured } else if (buttonPress == ShortPress2) { secTicker = 0; s2Button = true; // Button Event has occured } // Gather response from LoRa Module if available if ( MOTEapp_getModemResponse() ) readMessage = true; else readMessage = false; // Handle Timed Task if ( (runningState == runningUplink) || (runningState == runningSensorMenu) ) { // Get Sensor Data every 10mS if (m10SecTicker >= LightCapTime) { uint16_t Traw = 0; moteApp_delayms(10); for(uint8_t i = 32; i>0; i--) { light = (light + ADC_GetConversion(Light_channel)) / 2; } moteApp_delayms(10); for(uint8_t i = 32; i>0; i--) { Traw = (Traw + ADC_GetConversion(Temp_channel)) / 2; } temperature = ADC_TempConversion(Traw); m10SecTicker = 0; } } // Sleep Event if idle if(secTicker) { if (secTicker >= SleepTimeOut) { gotoSleep = true; secTicker = 0; } } switch(moteState) { default: // Invalid while(1); // Hold For Error; break; case MOTE_STARTUP: oled_clear(); oled_putString("MOTE Mode",1,0); oled_putString("Starting",2,1); oled_putString("ReRun PwrTst<S2>",0,3); activeState = moteStartup; moteState = MOTE_JOINING; break; case MOTE_JOINING: if ( moteJoiningProcess(readMessage, s2Button) ) { oled_clear(); oled_putString("Mobile Mote -App",0,0); oled_putString("Navigate Select", 0,2); oled_putString(" (S1) (S2) ", 0,3); runningState = runningEnter; moteState = MOTE_RUNNING; } break; case MOTE_RUNNING: moteRunningProcess(gotoNextState, s2Button, readMessage, gotoSleep); break; case MOTE_SWAP: // Do Nothing break; } return moteState; }