void SwitchS5IsPressed(uint16_t max_debounce_time_ms) { // check if switch level has changed and if so, debounce/save the new level if(SW_S5 != old_Sw.Sw_bits.S5) { old_Sw.Sw_bits.S5 = SwitchLevel(&SW_S5_PORT, SW_S5_PIN, max_debounce_time_ms); // Debounce,Save new value } }
//Loads current directory (including all levels it contains) void LEVELSELECT::LoadDirectory() { char levelPath[MAX_PATH]; GetDirectoryPath(&levelPath[0], ""); if (strlen(levelPath)+strlen(currentDirectory->name)>=MAX_PATH) { error("LEVELSELECT::SwitchDirectory", "FATAL: Path too long."); exit (1); } strcat(levelPath, currentDirectory->name); levelCount = 0; FreeLevelList(currentLevel); currentLevel = NULL; if (FILESYSTEMUTILITY::EnumerateFiles(levelPath, &levelCount, &addLevelListEntry)) { SwitchLevel(0); } else { logger(true, "WARN: No levels available (Got false from FILESYSTEMUTILITY::EnumerateFiles)"); } }
int main(void) { unsigned char iloop, jloop; char AddrString[30]; char ConstString[256]; InitializeSystem(); unsigned char temp, temp1, temp2, temp3, temp4; unsigned char ones_char, tens_char, huns_char; int16_t change_cnt; sprintf(OutString, "WiFly Pass_thru\nDemo"); putsLCD(OutString); // JKW starts here Delayms(5000); sprintf(OutString,"$$$"); putsWiFly(OutString); putsConsole(OutString); Delayms(5000); sprintf(OutString,"set comm open [\r\n"); putsConsole(OutString); putsWiFly(OutString); Delayms(1000); sprintf(OutString,"set wlan name Hogwarts\r\n"); putsConsole(OutString); putsWiFly(OutString); Delayms(1000); sprintf(OutString,"set wlan phrase pooKums496\r\n"); putsConsole(OutString); putsWiFly(OutString); Delayms(1000); sprintf(OutString,"set ftp timer 40\r\n"); putsConsole(OutString); putsWiFly(OutString); Delayms(1000); sprintf(OutString,"set comm close ]\r\n"); putsConsole(OutString); putsWiFly(OutString); Delayms(1000); sprintf(OutString,"save\r\n"); putsConsole(OutString); putsWiFly(OutString); Delayms(1000); // sprintf(OutString,"get everything\r\n"); // putsConsole(OutString); // putsWiFly(OutString); Delayms(200); sprintf(OutString, "Aug31 7:44AM \nputs only "); // columns 41, 59 putsConsole(OutString); Delayms(200); setLCDC(0x00); // point to 1st line Delayms(200); putsLCD(OutString); Delayms(2000); sprintf(OutString, "\r\n"); putsConsole(OutString); change_cnt = 0; for (iloop = 0; iloop <=5; iloop++) { Delayms(5000); sprintf(AddrString,"ftp put zzaq29_000.txt\r\n"); temp1 = (iloop % 10); ones_char = temp1 + 0x30; temp2 = (iloop - temp1)/10; tens_char = temp2 + 0x30; temp3 = (iloop - temp2*10 - temp1)/100; huns_char = temp3 + 0x30; AddrString[15] = huns_char; AddrString[16] = tens_char; AddrString[17] = ones_char; Delayms(5000); putsConsole(AddrString); Delayms(1000); putsWiFly(AddrString); sprintf(ConstString,"A9ABE296E34713800CC11D0D1E0FB197B36810D14F32085E4E50BFB685EC755E26C88F63A105284B0AC627FA90EF3B294D6D549C0A0D88E814B5A2C17794B1EBD1A064868BB377DFD5CD80218D73D3F0A18B642EFAFACEDDBA6E2694D27F3E7EE3B04A57D6CBBE452343D9428133C5209D763B2F776628529B94173B3568"); // 1009 temp4 = ConstString[change_cnt] - 0x01; if (temp4 < 0x30) { temp4 = 0x30; change_cnt++; if (change_cnt == 251) {change_cnt = 0;} temp4 = ConstString[change_cnt] - 0x01; } if ((temp4 < 0x41) && (temp4 > 0x39)) temp4 = 0x39; ConstString[change_cnt] = temp4; change_cnt++; if (change_cnt == 251) {change_cnt = 0;} temp = 0x00; while (temp != '.') {temp = U1RXREG; Delayms(10);} temp = 0x00; while (temp != '.') {temp = U1RXREG; Delayms(10);} temp = 0x00; while (temp != '.') {temp = U1RXREG; Delayms(10);} temp = 0x00; while (temp != '.') {temp = U1RXREG; Delayms(10);} temp = 0x00; while (temp != '.') {temp = U1RXREG; Delayms(10);} while (U1RXREG != '1') // [ = 0x5B, ] = 0x5D { putConsole(U1RXREG); Delayms(200); } putsConsole(ConstString); Delayms(1000); putsWiFly(ConstString); Delayms(10000); // Delayms(10000); sprintf(ConstString,"$$$"); putsConsole(ConstString); Delayms(1000); putsWiFly(ConstString); Delayms(1000); setLCDC(0x00); // point to 1st line Delayms(200); sprintf(OutString, "iloop = \nLoop to 25 "); OutString[9] = (char) (0x30 + iloop %10); OutString[8] = '0'; if ((iloop >= 10) && (iloop <= 19)) OutString[8] = '1'; if ((iloop >= 20) && (iloop <= 29)) OutString[8] = '2'; putsLCD(OutString); Delayms(10000); } // JKW ends here while(1) { // check if S4 pressed to trigger WiFly factory restoral if(0 == SwitchLevel(&SW_S4_PORT, SW_S4_PIN, SWITCH_DEBOUNCE_MS)) { sprintf(OutString,"\r\n\r\ninitiating WiFly factory reset...\r\n\r\n"); putsConsole(OutString); // drive GPIO9 high for 10ms before resetting the module RN_GPIO9 = 1; Delayms(1000); // Assert RESET for 10ms RN_RESET = 0; Delayms(100); RN_RESET = 1; Delayms(100); // toggle GPIO9 5 times, delaying at least 1 sec between toggles RN_GPIO9 = 0; Delayms(1200); RN_GPIO9 = 1; Delayms(1200); RN_GPIO9 = 0; Delayms(1200); RN_GPIO9 = 1; Delayms(1200); RN_GPIO9 = 0; Delayms(1200); RN_GPIO9 = 1; Delayms(1200); RN_GPIO9 = 0; Delayms(1200); RN_GPIO9 = 1; Delayms(1200); RN_GPIO9 = 0; Delayms(1200); // now toggle RESET to reboot the module and apply factory default settings RN_RESET = 0; Delayms(100); RN_RESET = 1; // wait for user to release S4 while(0 == SwitchLevel(&SW_S4_PORT, SW_S4_PIN, SWITCH_DEBOUNCE_MS)); } } } // main
int LEVELSELECT::Select() { const char noDirectoryName[] = "[kein Verzeichnis]"; BUTTON prevDirButton ({{10, windY - 100}, {90, windY - 50}}, 0, 3, 10, CYAN, "<", 20, YELLOW); BUTTON nextDirButton ({{windX - 100, windY - 100}, {windX - 10, windY - 50}}, 0, 3, 10, CYAN, ">", 20, YELLOW); BUTTON dirCaption ({{100, windY - 100}, {windX - 110, windY - 50}}, 3, 3, 10, CYAN, "(Directory)", 20, YELLOW); BUTTON prevButton ({{10, windY - 180}, {90, windY - 130}}, 0, 3, 10, CYAN, "<", 20, YELLOW); BUTTON nextButton ({{windX - 100, windY - 180}, {windX - 10, windY - 130}}, 0, 3, 10, CYAN, ">", 20, YELLOW); BUTTON selectButton ({{windX - 200, 10}, {windX - 10, 60}}, 0, 3, 10, CYAN, "Spiel starten", 20, YELLOW); BUTTON cancelButton ({{10, 10}, {190, 60}}, 0, 3, 10, CYAN, "Zurück", 20, YELLOW); BUTTON levelCaption ({{100, windY - 180}, {windX - 110, windY - 130}}, 3, 3, 10, CYAN, "(Levelname)", 20, YELLOW); AREA highscoreOutput {{100, 140}, {windX / 2 - 100, windY - 240}}; prevDirButton.assignKeyboardButton(0,'Q'); nextDirButton.assignKeyboardButton(0,'E'); prevButton .assignKeyboardButton(0,GLFW_KEY_LEFT ,'A'); nextButton .assignKeyboardButton(0,GLFW_KEY_RIGHT,'D'); levelCaption .assignKeyboardButton(0,'S'); cancelButton .assignKeyboardButton(0,GLFW_KEY_ESC); selectButton .assignKeyboardButton(0,GLFW_KEY_ENTER,GLFW_KEY_SPACE); ReloadHighscore(); prepare_GameLoop(); do { prepare_graphics(); char levelText[MAX_PATH]; if (GetLevel() != NULL) sprintf(levelText, "%s (%d/%d)", GetLevel()->name, GetLevel()->index + 1, GetLevelCount()); else strcpy(levelText, "[Kein Level vorhanden]"); levelCaption.setText(levelText); const char* directoryName; if (strlen(GetDirectory()->name) > 0) directoryName = GetDirectory()->name; else directoryName = noDirectoryName; char directoryText[strlen(directoryName) + 9]; sprintf(directoryText, "%s (%d/%d)", directoryName, GetDirectory()->index + 1, GetDirectoryCount()); dirCaption.setText(directoryText); //handle clicks if (cancelButton.clicked()) break; else if (selectButton.clicked() && isInputValid()) { currentLevel->score.setTimesPlayed(currentLevel->score.getTimesPlayed() + 1); return true; } else if (prevButton.clicked() || levelCaption.clicked() == 2) SwitchLevel(-1); else if (nextButton.clicked() || levelCaption.clicked() == 1) SwitchLevel(1); else if (prevDirButton.clicked() || dirCaption.clicked() == 2) SwitchDirectory(-1); else if (nextDirButton.clicked() || dirCaption.clicked() == 1) SwitchDirectory(1); //output prevDirButton.print(); nextDirButton.print(); dirCaption.print(); prevButton.print(); nextButton.print(); selectButton.print(); cancelButton.print(); levelCaption.print(); if (currentLevel != NULL) { drawBox({{windX/2 + 80, 140}, {windX - 110, windY - 240}}, 10, 3, WHITE); currentLevel->level->printPreview(); TIME time = currentLevel->score.getTime(); drawBox(highscoreOutput,10,3,WHITE); normalFont.printf({highscoreOutput.a.x + 20, highscoreOutput.b.y - 40}, taLEFT, "Highscore"); normalFont.printf({highscoreOutput.a.x + 20, highscoreOutput.b.y - 80}, taLEFT, "Züge: %d", currentLevel->score.getMoves()); normalFont.printf({highscoreOutput.a.x + 20, highscoreOutput.b.y - 120}, taLEFT, "Zeit: %02d:%02d:%05.2f", time.Hours, time.Minutes, time.Seconds); normalFont.printf({highscoreOutput.a.x + 20, highscoreOutput.b.y - 160}, taLEFT, "%d mal gespielt", currentLevel->score.getTimesPlayed()); } } while (complete_graphics()); logger(true, "LEVELSELECT: Cancelled, Returning false."); return false; }
int main(void) { unsigned char jloop; unsigned int iloop; char AddrString[30]; char ConstString[256]; InitializeSystem(); unsigned char temp, temp1, temp2, temp3, temp4; unsigned char ones_char, tens_char, huns_char; int16_t change_cnt; ODCAbits.ODA6 = 0; // This is for the Explorer-16 Demo Board TRISAbits.TRISA6 = 0; // This is for the Explorer-16 Demo Board // ODCCbits.ODC2 = 0; // TRISCbits.TRISC2 = 0; unsigned long i; GreenLEDState = 0; RedLEDState = 0; RTCCInit(); // initialization includes set the time and date TimeMinBinary = 0; while (TimeMinBinary < 3) { if (TenSecondTick == 1) { RTCCgrab(); TimeHourBinary = mRTCCDec2Bin(TimeHourBCD); TimeMinBinary = mRTCCDec2Bin(TimeMinBCD); TimeSecBinary = mRTCCDec2Bin(TimeSecBCD); TimeDayOfWeekBinary = mRTCCDec2Bin(TimeDayOfWeekBCD); TimeDayBinary = mRTCCDec2Bin(TimeDayBCD); TimeMonthBinary = mRTCCDec2Bin(TimeMonthBCD); TimeYearBinary = mRTCCDec2Bin(TimeYearBCD); sprintf(OutString, " : : \n / / 20 "); // columns 41, 59 // sprintf(OutString, "Sept4 1:00PM \nputs only "); // columns 41, 59 temp1 = (TimeHourBinary % 10); ones_char = temp1 + 0x30; temp2 = (TimeHourBinary - temp1)/10; tens_char = temp2 + 0x30; OutString[0] = tens_char; OutString[1] = ones_char; temp1 = (TimeMinBinary % 10); ones_char = temp1 + 0x30; temp2 = (TimeMinBinary - temp1)/10; tens_char = temp2 + 0x30; OutString[3] = tens_char; OutString[4] = ones_char; temp1 = (TimeSecBinary % 10); ones_char = temp1 + 0x30; temp2 = (TimeSecBinary - temp1)/10; tens_char = temp2 + 0x30; OutString[6] = tens_char; OutString[7] = ones_char; temp1 = (TimeDayOfWeekBinary % 10); ones_char = temp1 + 0x30; temp2 = (TimeDayOfWeekBinary - temp1)/10; tens_char = temp2 + 0x30; OutString[17] = tens_char; OutString[18] = ones_char; temp1 = (TimeDayBinary % 10); ones_char = temp1 + 0x30; temp2 = (TimeDayBinary - temp1)/10; tens_char = temp2 + 0x30; OutString[20] = tens_char; OutString[21] = ones_char; temp1 = (TimeMonthBinary % 10); ones_char = temp1 + 0x30; temp2 = (TimeMonthBinary - temp1)/10; tens_char = temp2 + 0x30; OutString[23] = tens_char; OutString[24] = ones_char; temp1 = (TimeYearBinary % 10); ones_char = temp1 + 0x30; temp2 = (TimeYearBinary - temp1)/10; tens_char = temp2 + 0x30; OutString[28] = tens_char; OutString[29] = ones_char; Delayms(200); setLCDC(0x00); // point to 1st line Delayms(2000); putsLCD(OutString); TenSecondTick = 0; } // if (TenSecondTick == 1) } // while(TimeMinBinary < 4) sprintf(OutString, "WiFly Pass_thru\nDemo"); putsLCD(OutString); // JKW starts here Delayms(5000); sprintf(OutString,"$$$"); putsWiFly(OutString); putsConsole(OutString); Delayms(5000); sprintf(OutString,"set comm open [\r\n"); putsConsole(OutString); putsWiFly(OutString); Delayms(1000); // sprintf(OutString,"set wlan ssid AMI\r\n"); // sprintf(OutString,"set wlan ssid Arthur$and$Matts$Internet\r\n"); sprintf(OutString,"set wlan ssid Hogwarts\r\n"); putsConsole(OutString); putsWiFly(OutString); Delayms(1000); // sprintf(OutString,"set wlan phrase hot7blue\r\n"); sprintf(OutString,"set wlan phrase pooKums496\r\n"); putsConsole(OutString); putsWiFly(OutString); Delayms(1000); sprintf(OutString,"set ftp timer 80\r\n"); putsConsole(OutString); putsWiFly(OutString); Delayms(1000); sprintf(OutString,"set comm close ]\r\n"); putsConsole(OutString); putsWiFly(OutString); Delayms(1000); sprintf(OutString,"set ftp dir /jackwaterman\r\n"); putsConsole(OutString); putsWiFly(OutString); Delayms(1000); sprintf(OutString,"set ftp user waterallusers\r\n"); putsConsole(OutString); putsWiFly(OutString); Delayms(1000); sprintf(OutString,"set ftp pass aRkeO7755123!\r\n"); putsConsole(OutString); putsWiFly(OutString); //User=jaycen is now waterallusers //Pass=jWes232740 is now aRkeO7755123! //Dir=../../ is now /jackwaterman Delayms(1000); sprintf(OutString,"save\r\n"); putsConsole(OutString); putsWiFly(OutString); // Delayms(1000); // sprintf(OutString,"get everything\r\n"); // putsConsole(OutString); // putsWiFly(OutString); Delayms(200); sprintf(OutString, "Sept7 8:00AM \nputs only "); // columns 41, 59 putsConsole(OutString); Delayms(200); setLCDC(0x00); // point to 1st line Delayms(200); putsLCD(OutString); Delayms(2000); sprintf(OutString, "\r\n"); putsConsole(OutString); change_cnt = 0; // sprintf(ConstString,"A9ABE296E34713800CC11D0D1E0FB197B36810D14F32085E4E50BFB685EC755E26C88F63A105284B0AC627FA90EF3B294D6D549C0A0D88E814B5A2C17794B1EBD1A064868BB377DFD5CD80218D73D3F0A18B642EFAFACEDDBA6E2694D27F3E7EE3B04A57D6CBBE452343D9428133C5209D763B2F776628529B94173B3568"); // 1009 for (iloop = 0; iloop <=999; iloop++) { Delayms(500); // worked well with 5000 sprintf(AddrString,"ftp put sept9__000.txt\r\n"); // sprintf(AddrString,"ftp put arthur_000.txt\r\n"); temp1 = (iloop % 10); ones_char = temp1 + 0x30; temp2 = ((iloop - temp1) % 100)/10; tens_char = temp2 + 0x30; temp3 = (iloop - temp2*10 - temp1)/100; huns_char = temp3 + 0x30; AddrString[15] = huns_char; AddrString[16] = tens_char; AddrString[17] = ones_char; Delayms(500); // worked well with 5000 putsConsole(AddrString); Delayms(500); putsWiFly(AddrString); sprintf(ConstString,"A9ABE296E34713800CC11D0D1E0FB197B36810D14F32085E4E50BFB685EC755E26C88F63A105284B0AC627FA90EF3B294D6D549C0A0D88E814B5A2C17794B1EBD1A064868BB377DFD5CD80218D73D3F0A18B642EFAFACEDDBA6E2694D27F3E7EE3B04A57D6CBBE452343D9428133C5209D763B2F776628529B94173B3568"); // 1009 temp4 = ConstString[change_cnt] - 0x01; if (temp4 < 0x30) { temp4 = 0x30; change_cnt++; if (change_cnt == 251) {change_cnt = 0;} temp4 = ConstString[change_cnt] - 0x01; } if ((temp4 < 0x41) && (temp4 > 0x39)) temp4 = 0x39; ConstString[change_cnt] = temp4; change_cnt++; if (change_cnt == 251) {change_cnt = 0;} temp = 0x00; kickout_seconds = 0; // kicks out if takes longer than 2 minutes RTCCgrab(); TimeHourBinary = mRTCCDec2Bin(TimeHourBCD); TimeMinBinary = mRTCCDec2Bin(TimeMinBCD); TimeSecBinary = mRTCCDec2Bin(TimeSecBCD); time_mark1 = TimeHourBinary*3600 + TimeMinBinary*60+ TimeSecBinary; TimeHourBinarySave = TimeHourBinary; while ( (U1RXREG != '1') && (kickout_seconds < 60) ) // [ = 0x5B, ] = 0x5D { putConsole(U1RXREG); RTCCgrab(); TimeHourBinary = mRTCCDec2Bin(TimeHourBCD); TimeMinBinary = mRTCCDec2Bin(TimeMinBCD); TimeSecBinary = mRTCCDec2Bin(TimeSecBCD); time_mark2 = TimeHourBinary*3600 + TimeMinBinary*60+ TimeSecBinary; if (TimeHourBinary < TimeHourBinarySave) time_mark2 = time_mark2 + 24*3600; kickout_seconds = time_mark2 - time_mark1; Delayms(200); } if (kickout_seconds < 60) { putsConsole(ConstString); Delayms(500); putsWiFly(ConstString); // Delayms(7000); // works OK when ftp_timeout = 40, 1 every 12 sec // Delayms(21000);// works OK when ftp_timeout = 40, 1 every 24 sec Delayms(12000); // works OK when ftp_timeout = 40, 1 every 16 sec } sprintf(ConstString,"$$$"); putsConsole(ConstString); Delayms(500); putsWiFly(ConstString); Delayms(500); setLCDC(0x00); // point to 1st line Delayms(200); sprintf(OutString, "iloop = \nLoop to 1000 "); temp1 = (iloop % 10); ones_char = temp1 + 0x30; // temp2 = (iloop - temp1)/10; temp2 = ((iloop - temp1) % 100)/10; tens_char = temp2 + 0x30; temp3 = (iloop - temp2*10 - temp1)/100; huns_char = temp3 + 0x30; OutString[8] = huns_char; OutString[9] = tens_char; OutString[10] = ones_char; putsLCD(OutString); Delayms(1000); // worked well with 10000 } // JKW ends here while(1) { // check if S4 pressed to trigger WiFly factory restoral if(0 == SwitchLevel(&SW_S4_PORT, SW_S4_PIN, SWITCH_DEBOUNCE_MS)) { sprintf(OutString,"\r\n\r\ninitiating WiFly factory reset...\r\n\r\n"); putsConsole(OutString); // drive GPIO9 high for 10ms before resetting the module RN_GPIO9 = 1; Delayms(1000); // Assert RESET for 10ms RN_RESET = 0; Delayms(100); RN_RESET = 1; Delayms(100); // toggle GPIO9 5 times, delaying at least 1 sec between toggles RN_GPIO9 = 0; Delayms(1200); RN_GPIO9 = 1; Delayms(1200); RN_GPIO9 = 0; Delayms(1200); RN_GPIO9 = 1; Delayms(1200); RN_GPIO9 = 0; Delayms(1200); RN_GPIO9 = 1; Delayms(1200); RN_GPIO9 = 0; Delayms(1200); RN_GPIO9 = 1; Delayms(1200); RN_GPIO9 = 0; Delayms(1200); // now toggle RESET to reboot the module and apply factory default settings RN_RESET = 0; Delayms(100); RN_RESET = 1; // wait for user to release S4 while(0 == SwitchLevel(&SW_S4_PORT, SW_S4_PIN, SWITCH_DEBOUNCE_MS)); } } } // main
void initSwitchS3(uint16_t max_debounce_time_ms) { TRIS_SW_S3 = 1; // set as digital input old_Sw.Sw_bits.S3 = SwitchLevel(&SW_S3_PORT, SW_S3_PIN, max_debounce_time_ms); // save new value }
int main(void) { unsigned char iloop, jloop; char AddrString[30]; char ConstString[70]; InitializeSystem(); unsigned char temp1, temp2, temp3, temp4; unsigned char ones_char; unsigned char tens_char; sprintf(OutString, "WiFly Pass_thru\nDemo"); putsLCD(OutString); // JKW starts here Delayms(5000); sprintf(OutString,"$$$"); putsWiFly(OutString); putsConsole(OutString); Delayms(5000); sprintf(OutString,"set comm open *OPEN*\r\n"); putsConsole(OutString); putsWiFly(OutString); Delayms(1000); sprintf(OutString,"set wlan name Hogwarts\r\n"); putsConsole(OutString); putsWiFly(OutString); Delayms(1000); sprintf(OutString,"set wlan phrase pooKums496\r\n"); putsConsole(OutString); putsWiFly(OutString); Delayms(1000); sprintf(OutString,"set ftp timer 40\r\n"); putsConsole(OutString); putsWiFly(OutString); Delayms(1000); sprintf(OutString,"set comm close *CLOS*\r\n"); putsConsole(OutString); putsWiFly(OutString); Delayms(1000); sprintf(OutString,"save\r\n"); putsConsole(OutString); putsWiFly(OutString); Delayms(1000); // sprintf(OutString,"get everything\r\n"); // putsConsole(OutString); // putsWiFly(OutString); Delayms(200); sprintf(OutString, "Aug29 5:54AM \nputs only "); // columns 41, 59 putsConsole(OutString); Delayms(200); setLCDC(0x00); // point to 1st line Delayms(200); putsLCD(OutString); Delayms(2000); sprintf(OutString, "\r\n"); putsConsole(OutString); // sprintf(ConstString,"A9ABE296E34713800CC11D0D1E0FB19"); // "FEA626636B6656949F2CFD4873E51691\r\n"); for (iloop = 0; iloop <=5; iloop++) { Delayms(1000); // sprintf(OutString,"get ftp\r\n"); // putsConsole(OutString); // putsWiFly(OutString); // sprintf(OutString,"$$$"); // putsWiFly(OutString); // putsConsole(OutString); Delayms(5000); if (iloop == 0) sprintf(AddrString,"ftp put zzak29_00.txt\r\n"); if (iloop == 1) sprintf(AddrString,"ftp put zzak29_01.txt\r\n"); if (iloop == 2) sprintf(AddrString,"ftp put zzak29_02.txt\r\n"); if (iloop == 3) sprintf(AddrString,"ftp put zzak29_03.txt\r\n"); if (iloop == 4) sprintf(AddrString,"ftp put zzak29_04.txt\r\n"); if (iloop == 5) sprintf(AddrString,"ftp put zzak29_05.txt\r\n"); // temp1 = (iloop % 10); // ones_char = temp1 + 0x30; // temp2 = (iloop - temp1)/10; // tens_char = temp2 + 0x30; // AddrString[15] = tens_char; // AddrString[16] = ones_char; // Delayms(5000); putsConsole(AddrString); // Delayms(2000); // sprintf(OutString,"\r\n"); // putsConsole(OutString); Delayms(1000); putsWiFly(AddrString); Delayms(6000); // sprintf(ConstString,"the once and xxth future king\r\n"); // ConstString[13] = tens_char; // ConstString[14] = ones_char; if (iloop == 0) sprintf(ConstString,"A9ABE296E34713800CC11D0D1E0FB19*CLOS*"); if (iloop == 1) sprintf(ConstString,"99ABE296E34713800CC11D0D1E0FB19*CLOS*"); if (iloop == 2) sprintf(ConstString,"98ABE296E34713800CC11D0D1E0FB19*CLOS*"); if (iloop == 3) sprintf(ConstString,"989BE296E34713800CC11D0D1E0FB19*CLOS*"); if (iloop == 4) sprintf(ConstString,"989AE296E34713800CC11D0D1E0FB19*CLOS*"); if (iloop == 5) sprintf(ConstString,"989AD296E34713800CC11D0D1E0FB19*CLOS*"); // temp4 = ConstString[iloop] - 0x01; // if (temp4 < 0x30) temp4 = 0x46; //'F' // if ((temp4 < 0x41) && (temp4 > 0x39)) temp4 = 0x39; // ConstString[iloop] = temp4; putsConsole(ConstString); Delayms(1000); putsWiFly(ConstString); Delayms(10000); Delayms(10000); sprintf(ConstString,"$$$"); putsConsole(ConstString); Delayms(1000); putsWiFly(ConstString); Delayms(1000); setLCDC(0x00); // point to 1st line Delayms(200); sprintf(OutString, "iloop = \nLoop to 25 "); OutString[9] = (char) (0x30 + iloop %10); OutString[8] = '0'; if ((iloop >= 10) && (iloop <= 19)) OutString[8] = '1'; if ((iloop >= 20) && (iloop <= 29)) OutString[8] = '2'; putsLCD(OutString); // Delayms(2000); // sprintf(OutString,"\r\n"); // putsWiFly(OutString); // putsConsole(OutString); // Delayms(2000); // sprintf(OutString,"reboot\r\n"); // putsWiFly(OutString); // putsConsole(OutString); // Delayms(2000); // sprintf(OutString,"\r\n"); // putsWiFly(OutString); // putsConsole(OutString); // Delayms(10000); // sprintf(OutString,"$$$"); // putsWiFly(OutString); // putsConsole(OutString); Delayms(10000); } // JKW ends here while(1) { // check if S4 pressed to trigger WiFly factory restoral if(0 == SwitchLevel(&SW_S4_PORT, SW_S4_PIN, SWITCH_DEBOUNCE_MS)) { sprintf(OutString,"\r\n\r\ninitiating WiFly factory reset...\r\n\r\n"); putsConsole(OutString); // drive GPIO9 high for 10ms before resetting the module RN_GPIO9 = 1; Delayms(1000); // Assert RESET for 10ms RN_RESET = 0; Delayms(100); RN_RESET = 1; Delayms(100); // toggle GPIO9 5 times, delaying at least 1 sec between toggles RN_GPIO9 = 0; Delayms(1200); RN_GPIO9 = 1; Delayms(1200); RN_GPIO9 = 0; Delayms(1200); RN_GPIO9 = 1; Delayms(1200); RN_GPIO9 = 0; Delayms(1200); RN_GPIO9 = 1; Delayms(1200); RN_GPIO9 = 0; Delayms(1200); RN_GPIO9 = 1; Delayms(1200); RN_GPIO9 = 0; Delayms(1200); // now toggle RESET to reboot the module and apply factory default settings RN_RESET = 0; Delayms(100); RN_RESET = 1; // wait for user to release S4 while(0 == SwitchLevel(&SW_S4_PORT, SW_S4_PIN, SWITCH_DEBOUNCE_MS)); } } } // main
int main(void) { char iloop, jloop; char AddrString[30]; char ConstString[35]; InitializeSystem(); char length; char ones_char; char tens_char; sprintf(OutString, "WiFly Pass_thru\nDemo"); putsLCD(OutString); // JKW starts here Delayms(5000); sprintf(OutString,"$$$"); putsWiFly(OutString); putsConsole(OutString); Delayms(5000); sprintf(OutString,"set comm open [\r\n"); putsConsole(OutString); putsWiFly(OutString); Delayms(1000); sprintf(OutString,"set wlan name Hogwarts\r\n"); putsConsole(OutString); putsWiFly(OutString); Delayms(1000); sprintf(OutString,"set wlan phrase pooKums496\r\n"); putsConsole(OutString); putsWiFly(OutString); Delayms(1000); sprintf(OutString,"set ftp timer 20\r\n"); putsConsole(OutString); putsWiFly(OutString); Delayms(1000); sprintf(OutString,"set comm close ]\r\n"); putsConsole(OutString); putsWiFly(OutString); Delayms(1000); sprintf(OutString,"save\r\n"); putsConsole(OutString); putsWiFly(OutString); Delayms(1000); // sprintf(OutString,"get everything\r\n"); // putsConsole(OutString); // putsWiFly(OutString); Delayms(200); sprintf(OutString, "Aug26 6:07AM \nputs only "); // columns 41, 59 putsConsole(OutString); Delayms(200); setLCDC(0x00); // point to 1st line Delayms(200); putsLCD(OutString); Delayms(2000); sprintf(OutString, "\r\n"); putsConsole(OutString); for (iloop = 0; iloop <=13; iloop++) { Delayms(1000); // sprintf(OutString,"get ftp\r\n"); // putsConsole(OutString); // putsWiFly(OutString); // sprintf(OutString,"$$$"); // putsWiFly(OutString); // putsConsole(OutString); Delayms(5000); sprintf(AddrString,"ftp put aaad26_00.txt\r\n"); ones_char = (iloop % 10); length = (iloop - ones_char)/10; ones_char = ones_char + 0x30; tens_char = length + 0x30; AddrString[15] = tens_char; AddrString[16] = ones_char; Delayms(5000); putsConsole(AddrString); Delayms(2000); sprintf(OutString,"\r\n"); putsConsole(OutString); Delayms(1000); putsWiFly(AddrString); Delayms(2000); sprintf(ConstString,"the once and xxth future king\r\n"); ConstString[13] = tens_char; ConstString[14] = ones_char; putsConsole(ConstString); Delayms(1000); putsWiFly(ConstString); Delayms(10000); setLCDC(0x00); // point to 1st line Delayms(200); sprintf(OutString, "iloop = \nLoop to 25 "); OutString[9] = (char) (0x30 + iloop %10); OutString[8] = '0'; if ((iloop >= 10) && (iloop <= 19)) OutString[8] = '1'; if ((iloop >= 20) && (iloop <= 29)) OutString[8] = '2'; putsLCD(OutString); Delayms(2000); sprintf(OutString,"\r\n"); putsWiFly(OutString); putsConsole(OutString); Delayms(2000); sprintf(OutString,"reboot\r\n"); putsWiFly(OutString); putsConsole(OutString); Delayms(2000); sprintf(OutString,"\r\n"); putsWiFly(OutString); putsConsole(OutString); Delayms(10000); sprintf(OutString,"$$$"); putsWiFly(OutString); putsConsole(OutString); Delayms(10000); } // JKW ends here while(1) { // check if S4 pressed to trigger WiFly factory restoral if(0 == SwitchLevel(&SW_S4_PORT, SW_S4_PIN, SWITCH_DEBOUNCE_MS)) { sprintf(OutString,"\r\n\r\ninitiating WiFly factory reset...\r\n\r\n"); putsConsole(OutString); // drive GPIO9 high for 10ms before resetting the module RN_GPIO9 = 1; Delayms(1000); // Assert RESET for 10ms RN_RESET = 0; Delayms(100); RN_RESET = 1; Delayms(100); // toggle GPIO9 5 times, delaying at least 1 sec between toggles RN_GPIO9 = 0; Delayms(1200); RN_GPIO9 = 1; Delayms(1200); RN_GPIO9 = 0; Delayms(1200); RN_GPIO9 = 1; Delayms(1200); RN_GPIO9 = 0; Delayms(1200); RN_GPIO9 = 1; Delayms(1200); RN_GPIO9 = 0; Delayms(1200); RN_GPIO9 = 1; Delayms(1200); RN_GPIO9 = 0; Delayms(1200); // now toggle RESET to reboot the module and apply factory default settings RN_RESET = 0; Delayms(100); RN_RESET = 1; // wait for user to release S4 while(0 == SwitchLevel(&SW_S4_PORT, SW_S4_PIN, SWITCH_DEBOUNCE_MS)); } } } // main