int is_running_in_strip() { // uses a hack to detect if we're running from an eActivity strip: // if the first pixel of the VRAM (first pixel of the status bar) is not white, then we are in a strip // (eActivity turns the statusbar background into a checkerbox when in a strip, // unless our code messes with the statusbar flags, which this add-in doesn't do. // the first pixel of the checkerboard is not white) DisplayStatusArea(); // otherwise, we don't know if(Bdisp_GetPoint_VRAM( 0, 0 ) != COLOR_WHITE) return 1; else return 0; }
void viewTOTPcode(totp* tkn) { unsigned short key = 0; int keyCol, keyRow; Bdisp_AllClr_VRAM(); drawScreenTitle(tkn->name); int shown_since_beginning = 0; while(key != KEY_PRGM_EXIT && key != KEY_PRGM_LEFT) { int ThirtySecCode = computeTOTP(tkn); char buffer[10]; itoa_zeropad(tkn->totpcode, buffer, 6); long long int ms_spent_ll = currentUTCUEBT() - (long long int)ThirtySecCode * 30LL * 1000LL; int ms_spent = (int)(ms_spent_ll); drawCircularCountdownIndicator(LCD_WIDTH_PX/2, 104, 44, COLOR_BLACK, COLOR_WHITE, (ms_spent*43)/30000, getCurrentSecond() < 30 ? 0 : 1); // fade in/out animation for text int val = 0; if(ms_spent >= 29000) { val += (-29000 + ms_spent)/4; } else if (ms_spent <= 1020) { val += (1020 - ms_spent)/4; } int color = drawRGB24toRGB565(val, val, val); printCentered(buffer, 164, color, COLOR_WHITE); if(ms_spent < 2500) shown_since_beginning = 1; else if(ms_spent < 15000 && shown_since_beginning) DefineStatusMessage((char*)totpHelpMessages[(ms_spent-2500)/2500], 1, 0, 0); else DefineStatusMessage((char*)"", 1, 0, 0); DisplayStatusArea(); Bdisp_PutDisp_DD(); key = PRGM_GetKey(); if(key == KEY_PRGM_MENU) GetKeyWait_OS(&keyCol, &keyRow, 2, 0, 0, &key); //this is here to handle the Menu key if(key == KEY_PRGM_OPTN) { DefineStatusMessage((char*)"", 1, 0, 0); GetKeyWait_OS(&keyCol, &keyRow, 2, 0, 0, &key); // clear keybuffer RTCunadjustedWizard(0, 1); setTimezone(); return; // so we don't have to redraw etc. // Also, this way the Shift+Menu instruction shown in the adjustment wizard becomes vali // immediately, which is great if the user wants to repeat the adjustment. } } DefineStatusMessage((char*)"", 1, 0, 0); // clear keybuffer: GetKeyWait_OS(&keyCol, &keyRow, 2, 0, 0, &key); }
void check_do_graph() { if(has_drawn_graph) { has_drawn_graph = 0; int key; int fkeymenu = 0; while(1) { DisplayStatusArea(); if(fkeymenu == 1) drawFkeyLabels(0x005F, 0x0060, 0x0061); // INITIAL, TRIG, STANDRD GetKey(&key); double xmin, xmax, ymin, ymax, xrange, yrange; get_xyminmax(&xmin, &xmax, &ymin, &ymax); xrange = xmax - xmin; yrange = ymax - ymin; if(fkeymenu == 0) { if(key == KEY_CTRL_LEFT || key == KEY_CTRL_RIGHT) { if(key==KEY_CTRL_LEFT) { xmin -= xrange * 0.15; xmax -= xrange * 0.15; } else { xmin += xrange * 0.15; xmax += xrange * 0.15; } // easier than having to set the symbols in the complicated eigenmath system: static char command[100]; sprintf(command, "xrange=(%g,%g)", xmin, xmax); execution_in_progress = 1; has_drawn_graph = 0; run(command); run(expr); execution_in_progress = 0; } else if(key == KEY_CTRL_DOWN || key == KEY_CTRL_UP) { if(key==KEY_CTRL_DOWN) { ymin -= yrange * 0.15; ymax -= yrange * 0.15; } else { ymin += yrange * 0.15; ymax += yrange * 0.15; } // easier than having to set the symbols in the complicated eigenmath system: static char command[100]; sprintf(command, "yrange=(%g,%g)", ymin, ymax); execution_in_progress = 1; has_drawn_graph = 0; run(command); run(expr); execution_in_progress = 0; } else if(key == KEY_CHAR_PLUS || key == KEY_CHAR_MINUS) { if(key==KEY_CHAR_PLUS) { // 0.75 is 3/4 xmin = xmin * 0.75; xmax = xmax * 0.75; ymin = ymin * 0.75; ymax = ymax * 0.75; } else { // 1.(3), or 1/(3/4), or 4/3 xmin = xmin * 4.0/3.0; xmax = xmax * 4.0/3.0; ymin = ymin * 4.0/3.0; ymax = ymax * 4.0/3.0; } // easier than having to set the symbols in the complicated eigenmath system: static char command[100]; sprintf(command, "yrange=(%g,%g)", ymin, ymax); execution_in_progress = 1; run(command); sprintf(command, "xrange=(%g,%g)", xmin, xmax); has_drawn_graph = 0; run(command); run(expr); execution_in_progress = 0; } else if(key == KEY_CTRL_F3) { fkeymenu = 1; key = 0; } else if(key == KEY_CTRL_EXIT || key==KEY_CTRL_F6) break; } if(fkeymenu == 1) { if(key == KEY_CTRL_F1) { execution_in_progress = 1; run("xrange=(-10,10)"); run("yrange=(-10,10)"); has_drawn_graph = 0; run(expr); execution_in_progress = 0; } else if(key == KEY_CTRL_F2) { execution_in_progress = 1; static char command[100]; sprintf(command, "xrange=(%g,%g)", -3.0*M_PI, 3.0*M_PI); run(command); run("yrange=(-1.6, 1.6)"); has_drawn_graph = 0; run(expr); execution_in_progress = 0; } else if(key == KEY_CTRL_F3) { execution_in_progress = 1; run("xrange=(-10,10)"); run("yrange=(-5,5)"); has_drawn_graph = 0; run(expr); execution_in_progress = 0; } else if(key == KEY_CTRL_EXIT) { fkeymenu = 0; execution_in_progress = 1; has_drawn_graph = 0; run(expr); execution_in_progress = 0; } } } } }