// ************************************************************************************************* // @fn display_alt_accumulator // @brief Display altitude accumulator routine. Supports display in meters and feet. // @param u8 line LINE1 // u8 update DISPLAY_LINE_UPDATE_FULL, DISPLAY_LINE_UPDATE_PARTIAL, DISPLAY_LINE_CLEAR // @return none // ************************************************************************************************* void display_alt_accumulator (u8 line, u8 update) { s32 temp; u8 * str; // show our altitude accumulator numbers on the second line if ( (update==DISPLAY_LINE_UPDATE_FULL) || (update==DISPLAY_LINE_UPDATE_PARTIAL) ) { // Show "ALtA" on top line display_chars(LCD_SEG_L1_3_0, (u8*)"ALTA", SEG_ON); // if the altitude accumulator is currently disabled, we've got nothing else to display so exit if (alt_accum_enable == 0) { clear_line(LINE2); display_chars(LCD_SEG_L2_4_0, (u8*)" OFF ", SEG_ON); // display "OFF" on bottom line return; } // Otherwise the accumulator is running, so display on the second line whatever alt_accum_displaycode // says to display, in metres or feet as appropriate. if (alt_accum_displaycode>2) alt_accum_displaycode=0; // sanity check // light up "m" or "ft" display symbol as appropriate if (sys.flag.use_metric_units) display_symbol(LCD_UNIT_L1_M, SEG_ON); // metres symbol else display_symbol(LCD_UNIT_L1_FT, SEG_ON); // or feet symbol if (alt_accum_displaycode==0) { // Display current altitude relative to the accumulator's starting point // "DIFF" means difference between starting elevation & current elevation display_chars(LCD_SEG_L1_3_0, (u8*)"DIFF", SEG_ON); // top line display message start_altitude_measurement(); stop_altitude_measurement(); // grab our current altitude temp = sAlt.altitude - alt_accum_startpoint; // difference between starting altitude & current altitude if (sys.flag.use_metric_units==0) temp = (temp*328)/100; // convert to feet if necessary clear_line(LINE2); // clear the bottom line of the display if (temp < 0) { // if altitude is a negative number... display_char(LCD_SEG_L2_4, '-', SEG_ON); // display - (negative sign) character at start of second line temp = 0 - temp; // make altitude a positive number again so we can display it if (temp>9999) temp = 9999; // we can only display 4 digits for a negative number str = itoa(temp, 4, 3); // 4 digits, up to 3 leading blank digits display_chars(LCD_SEG_L2_3_0, str, SEG_ON); // display altitude difference on bottom line (4 digits) return; } else // otherwise altitude difference is a positive number { str = itoa(temp, 5, 4); // 5 digits, up to 4 leading blank digits display_chars(LCD_SEG_L2_4_0, str, SEG_ON); // display altitude difference on bottom line (5 digits) return; } } else if (alt_accum_displaycode==1) { // Display total accumulated elevation gain. Remember we might currently be going uphill // so we need to check for, and include, any current elevation gain display_chars(LCD_SEG_L1_3_0, (u8*)"ACCA", SEG_ON); // top line display message clear_line(LINE2); // clear the bottom line of the display if (alt_accum__accumtotal<0) alt_accum__accumtotal = 0; // accumulated total should never be negative! temp = alt_accum__accumtotal; // local copy of accumulated total // Now we need to add on any vertical gained recently, that hasn't yet been included in alt_accum__accumtotal // This only happens if we're currently going uphill, and we've above our last valley / dip elevation if (alt_accum_direction && (sAlt.altitude>alt_accum_lastpeakdip)) // if we're going up, and we're higher than our last dip (valley) altitude temp += sAlt.altitude - alt_accum_lastpeakdip; // then add the vertical we've gained so far above that last dip / valley point // display the result str = itoa(temp, 5, 4); // 5 digits, up to 4 leading blank digits display_chars(LCD_SEG_L2_4_0, str, SEG_ON); // display peak altitude on bottom line (5 digits) return; } else { // Display maximum altitude found so far display_chars(LCD_SEG_L1_3_0, (u8*)"PEAK", SEG_ON); // top line display message clear_line(LINE2); // clear the bottom line of the display temp = alt_accum_max; // local copy of peak altitude if (temp < 0) temp = 0; // I can't be bothered displaying a negative number! So make it zero if it is. str = itoa(temp, 5, 4); // 5 digits, up to 4 leading blank digits display_chars(LCD_SEG_L2_4_0, str, SEG_ON); // display peak altitude on bottom line (5 digits) return; } } // clear out - we're finished else if (update == DISPLAY_LINE_CLEAR) { clear_line(LINE2); // clear off the altitude display from the second line // should really try to get the date displayed here again // Clean up function-specific segments before leaving function display_symbol(LCD_UNIT_L1_M, SEG_OFF); display_symbol(LCD_UNIT_L1_FT, SEG_OFF); display_symbol(LCD_SYMB_ARROW_DOWN, SEG_OFF); } }
void update_display(void){ int i; static int started_waiting = TRUE; static int block = FALSE; static int offset = 0; static int finished = TRUE; static int pad = 0; static BYTE saved_digits[COLSX] = {0x73,0x79,0x78,0x79}; static int prev_cursor_pos = 0; switch(display_flag){ case CHANGED: cursor_blink = FALSE; switch(finished){ case FALSE: switch(block){ case TRUE: printf("Blocked\n"); break; case FALSE: display_flag = WRITING; for(i=0;i<COLSX;i++){ digits[i] = 0; } block = blocking; offset = 0; break; default: break; } break; case TRUE: display_flag = WRITING; finished = FALSE; block = blocking; offset = 0; break; default: break; } break; case WRITING: switch(finished){ case FALSE: if(offset == 0){ for(i=0;i<COLSX;i++){ digits[i] = digits[i+1]; } digits[3] = 0; // Make space for new string } if(display_buffer[offset] != 0){ while(display_buffer[offset] == '.' && display_buffer[offset] != 0){ digits[3] |= CURSOR_VALUE; offset++; } for(i=0;i<3;i++){ digits[i] = digits[i+1]; } digits[3] = display_char(display_buffer[offset]); offset++; } else{ finished = TRUE; for(i=0;i<COLSX;i++){ digits[i] = digits[i+1]; } digits[3] = 0; // Space between end of string and restored digits if(padding == TRUE){ pad = 4; } } break; case TRUE: if(pad){ for(i=0;i<COLSX;i++){ digits[i] = digits[i+1]; } digits[3] = saved_digits[COLSX-pad]; pad--; } else{ blocking = FALSE; block = blocking; offset = 0; started_waiting = TRUE; display_flag = WAITING; } break; default: break; } break; case INPUTTING: for(i=0;i<COLSX;i++){ digits[i] = display_char(input_buffer[i+cursor_offset]); saved_digits[i] = digits[i]; } cursor_blink = TRUE; block = FALSE; display_flag = WAITING; break; case WAITING: if(started_waiting){ for(i=0;i<COLSX;i++){ saved_digits[i] = digits[i]; // Copy current display } started_waiting = FALSE; cursor_blink = TRUE; } if(cursor_blink == TRUE){ if(prev_cursor_pos != cursor_pos){ digits[prev_cursor_pos] &= NO_CURSOR; prev_cursor_pos = cursor_pos; } if(cursor_pos < COLSX){ digits[cursor_pos] ^= CURSOR_VALUE; } } break; default: break; } }
// ************************************************************************************************* // @fn display_acceleration // @brief Display routine. // @param u8 line LINE1 // u8 update DISPLAY_LINE_UPDATE_FULL, DISPLAY_LINE_CLEAR // @return none // ************************************************************************************************* void display_acceleration(u8 line, u8 update) { u8 *str; u8 raw_data; u16 accel_data; // Show warning if acceleration sensor was not initialised properly if (!as_ok) { display_chars(LCD_SEG_L1_2_0, (u8 *) "ERR", SEG_ON); } else { // Redraw whole screen if (update == DISPLAY_LINE_UPDATE_FULL) { { // Start acceleration sensor if (!is_acceleration_measurement()) { // Clear previous acceleration value sAccel.data = 0; // Start sensor cma_as_start(); // Set timeout counter sAccel.timeout = ACCEL_MEASUREMENT_TIMEOUT; // Set mode sAccel.mode = ACCEL_MODE_ON; // Start with Y-axis values sAccel.view_style = DISPLAY_ACCEL_Y; } // Display decimal point display_symbol(LCD_SEG_L1_DP1, SEG_ON); } } else if (update == DISPLAY_LINE_UPDATE_PARTIAL) { // Convert X/Y/Z values to mg switch (sAccel.view_style) { case DISPLAY_ACCEL_X: raw_data = sAccel.xyz[0]; display_char(LCD_SEG_L1_3, 'X', SEG_ON); break; case DISPLAY_ACCEL_Y: raw_data = sAccel.xyz[1]; display_char(LCD_SEG_L1_3, 'Y', SEG_ON); break; default: raw_data = sAccel.xyz[2]; display_char(LCD_SEG_L1_3, 'Z', SEG_ON); break; } accel_data = convert_acceleration_value_to_mgrav(raw_data) / 10; // Filter acceleration accel_data = (u16) ((accel_data * 0.2) + (sAccel.data * 0.8)); // Store average acceleration sAccel.data = accel_data; // Display acceleration in x.xx format str = int_to_array(accel_data, 3, 0); display_chars(LCD_SEG_L1_2_0, str, SEG_ON); // Display sign if (acceleration_value_is_positive(raw_data)) { display_symbol(LCD_SYMB_ARROW_UP, SEG_ON); display_symbol(LCD_SYMB_ARROW_DOWN, SEG_OFF); } else { display_symbol(LCD_SYMB_ARROW_UP, SEG_OFF); display_symbol(LCD_SYMB_ARROW_DOWN, SEG_ON); } } else if (update == DISPLAY_LINE_CLEAR) { // Stop acceleration sensor cma_as_stop(); // Clear mode sAccel.mode = ACCEL_MODE_OFF; // Clean up display display_symbol(LCD_SEG_L1_DP1, SEG_OFF); display_symbol(LCD_SYMB_ARROW_UP, SEG_OFF); display_symbol(LCD_SYMB_ARROW_DOWN, SEG_OFF); } } }
void display_string(char *str) { uint8_t i; for(i=0; str[i]; i++) display_char(str[i]); }
// ************************************************************************************************* // @fn display_stopwatch // @brief Stopwatch user routine. Sx starts/stops stopwatch, but does not reset count. // @param u8 line LINE2 // u8 update DISPLAY_LINE_UPDATE_PARTIAL, DISPLAY_LINE_UPDATE_FULL // @return none // ************************************************************************************************* void display_stopwatch(u8 line, u8 update) { u8 DisplayTime[8]; if((StopwatchMode == MODE_LAPTIMER) && (LAP_TimeFlag == LAP_CATCHED)) { memcpy(DisplayTime, LAP_Time, sizeof(DisplayTime)); } else { memcpy(DisplayTime, sStopwatch.time, sizeof(DisplayTime)); } // Partial line update only if (update == DISPLAY_LINE_UPDATE_PARTIAL) { if (display.flag.update_stopwatch) { if (sStopwatch.viewStyle == DISPLAY_DEFAULT_VIEW) { // Display MM:SS:hh // Check draw flag to minimize workload if(sStopwatch.drawFlag != 0) { switch(sStopwatch.drawFlag) { case 4: display_char(LCD_SEG_L2_5, DisplayTime[2], SEG_ON); case 3: display_char(LCD_SEG_L2_4, DisplayTime[3], SEG_ON); case 2: display_char(LCD_SEG_L2_3, DisplayTime[4], SEG_ON); case 1: display_char(LCD_SEG_L2_2, DisplayTime[5], SEG_ON); case 7: display_char(LCD_SEG_L2_1, DisplayTime[6], SEG_ON); case 8: display_char(LCD_SEG_L2_0, DisplayTime[7], SEG_ON); } } } else // DISPLAY_ALTERNATIVE_VIEW { // Display HH:MM:SS switch(sStopwatch.drawFlag) { case 6: display_char(LCD_SEG_L2_5, DisplayTime[0], SEG_ON); case 5: display_char(LCD_SEG_L2_4, DisplayTime[1], SEG_ON); case 4: display_char(LCD_SEG_L2_3, DisplayTime[2], SEG_ON); case 3: display_char(LCD_SEG_L2_2, DisplayTime[3], SEG_ON); case 2: display_char(LCD_SEG_L2_1, DisplayTime[4], SEG_ON); case 1: display_char(LCD_SEG_L2_0, DisplayTime[5], SEG_ON); } } } } // Redraw whole line else if (update == DISPLAY_LINE_UPDATE_FULL) { if (sStopwatch.viewStyle == DISPLAY_DEFAULT_VIEW) { // Display MM:SS:hh display_chars(LCD_SEG_L2_5_0, DisplayTime+2, SEG_ON); } else // DISPLAY_ALTERNATIVE_VIEW { // Display HH:MM:SS display_chars(LCD_SEG_L2_5_0, DisplayTime, SEG_ON); } if(StopwatchMode == MODE_LAPTIMER) { display_symbol(LCD_SEG_L2_COL1, SEG_ON_BLINK_ON); display_symbol(LCD_SEG_L2_COL0, SEG_ON_BLINK_ON); } else // MODE_STOPTIMER { display_symbol(LCD_SEG_L2_COL1, SEG_ON); display_symbol(LCD_SEG_L2_COL0, SEG_ON); } // Set stopwatch icon display_symbol(LCD_ICON_STOPWATCH, SEG_ON_BLINK_ON); } else if (update == DISPLAY_LINE_CLEAR) { // Clean up symbols when leaving function if (sStopwatch.state == STOPWATCH_STOP) { display_symbol(LCD_ICON_STOPWATCH, SEG_OFF_BLINK_OFF); } else { display_symbol(LCD_ICON_STOPWATCH, SEG_ON_BLINK_OFF); } display_symbol(LCD_SEG_L2_COL1, SEG_OFF_BLINK_OFF); display_symbol(LCD_SEG_L2_COL0, SEG_OFF_BLINK_OFF); } }
// ************************************************************************************************* // @fn mx_number_storage // @brief Set number in storage. // @param u8 line - ignored parameter // @return none // ************************************************************************************************* void mx_number_storage(u8 line) { u8 * str; s32 NumberTmp; // Prepare display clear_display_all(); // Display a "M" for "Memory" display_char(LCD_SEG_L1_3, 'M', SEG_ON); // Display storage index str = itoa(sNumStore.Index, 2, 1); display_chars(LCD_SEG_L1_1_0, str, SEG_ON); // Copy to temp if((sNumStore.Index == 0) && (sNumStore.Mem[0] != 0) && (sNumStore.State == STATE_LOCKED)) { NumberTmp = 0; } else { NumberTmp = sNumStore.Mem[sNumStore.Index]; } // Loop until strage is set or user breaks set while(1) { // Idle timeout: exit without saving if (sys.flag.idle_timeout) break; // NUM Button (short): save, then exit if (button.flag.num) { // Check key for locking mechanism if(sNumStore.Index == 0) { switch (sNumStore.State) { case STATE_UNLOCKED: if(NumberTmp != 0) { sNumStore.State = STATE_TEMP_UNLOCKED; sNumStore.Mem[sNumStore.Index] = NumberTmp; } break; case STATE_TEMP_UNLOCKED: if(NumberTmp != sNumStore.Mem[0]) { sNumStore.Mem[sNumStore.Index] = NumberTmp; } if(NumberTmp == 0) { sNumStore.State = STATE_UNLOCKED; sNumStore.Mem[sNumStore.Index] = NumberTmp; } break; case STATE_LOCKED: if(NumberTmp == sNumStore.Mem[0]) { sNumStore.State = STATE_TEMP_UNLOCKED; } break; default: sNumStore.State = STATE_LOCKED; sNumStore.Index = 0; break; } } else { // Store local variables in global sNumStore.Mem[sNumStore.Index] = NumberTmp; } display_symbol(LCD_SYMB_TOTAL, SEG_ON_BLINK_OFF); //Set display update flag display.flag.full_update = 1; break; } // Display/change the storage content set_value(&NumberTmp, 4, 0, 0, 9999, SETVALUE_DISPLAY_VALUE + SETVALUE_FAST_MODE + SETVALUE_ROLLOVER_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L2_3_0, display_value1); } // Clear button flag button.all_flags = 0; }
// ************************************************************************************************* // @fn mx_sidereal // @brief Sidereal Clock set routine. // has three layers of different configuration sets // @param u8 line LINE1, LINE2 // @return none // ************************************************************************************************* void mx_sidereal(u8 line) { u8 select; s32 hours; s32 minutes; s32 seconds; s32 lon_degrees[SIDEREAL_NUM_LON]; s32 lon_minutes[SIDEREAL_NUM_LON]; s32 lon_seconds[SIDEREAL_NUM_LON]; s32 sync; s32 heart; u8 level; s32 direction[SIDEREAL_NUM_LON]; s32 UTCoffset; u8 * str; int i; // Clear display clear_display_all(); // Convert global time to local variables hours = sSidereal_time.hour; minutes = sSidereal_time.minute; seconds = sSidereal_time.second; sync = sSidereal_time.sync; for(i=0; i<SIDEREAL_NUM_LON; i++) { if(sSidereal_time.lon[i].deg<0 || sSidereal_time.lon[i].min<0 || sSidereal_time.lon[i].sec<0) { direction[i]=0; lon_degrees[i] = -sSidereal_time.lon[i].deg; lon_minutes[i] = -sSidereal_time.lon[i].min; lon_seconds[i] = -sSidereal_time.lon[i].sec; } else { direction[i]=1; lon_degrees[i] = sSidereal_time.lon[i].deg; lon_minutes[i] = sSidereal_time.lon[i].min; lon_seconds[i] = sSidereal_time.lon[i].sec; } } UTCoffset = sTime.UTCoffset; // Init value index (start with Auto Sync selection) select = 0; heart =0; level=sSidereal_time.lon_selection; // Loop values until all are set or user breaks set while(1) { // Idle timeout: exit without saving if (sys.flag.idle_timeout) { display_symbol(LCD_SYMB_AM, SEG_OFF); display_symbol(LCD_UNIT_L1_DEGREE, SEG_OFF); display_symbol(LCD_SYMB_ARROW_UP, SEG_OFF); display_symbol(LCD_SYMB_ARROW_DOWN, SEG_OFF); break; } if( heart!=0 ) { if(select<=4) { //go to longitude settings if(heart>0) { select=5; level=0; } //go to time zone settings else { select=10; } clear_display_all(); display_symbol(LCD_SYMB_AM, SEG_OFF); } else if(select<=9) { if(heart<0) { //go to previous level if(level>0) { level-=1; select=5; } //go to time/sync settings else { select=0; } } else { //go to next level if(level<SIDEREAL_NUM_LON-1) { level+=1; select=5; } //go to time zone settings else { select=10; } } clear_display_all(); display_symbol(LCD_UNIT_L1_DEGREE, SEG_OFF); display_symbol(LCD_SYMB_ARROW_UP, SEG_OFF); display_symbol(LCD_SYMB_ARROW_DOWN, SEG_OFF); } else { //go to time/sync settings if(heart>0) { select=0; } //go to longitude settings else { select=5; level=SIDEREAL_NUM_LON-1; } clear_display_all(); display_symbol(LCD_SYMB_ARROW_UP, SEG_OFF); display_symbol(LCD_SYMB_ARROW_DOWN, SEG_OFF); } heart=0; } // Button STAR (short): save, then exit if (button.flag.star) { //store sync settings sSidereal_time.sync=sync; sTime.UTCoffset = UTCoffset; for(i=0; i<SIDEREAL_NUM_LON; i++) { //store direction as sign of longitude if(direction[i] & 0x1) { sSidereal_time.lon[i].deg = lon_degrees[i]; sSidereal_time.lon[i].min = lon_minutes[i]; sSidereal_time.lon[i].sec = lon_seconds[i]; } else { sSidereal_time.lon[i].deg = -lon_degrees[i]; sSidereal_time.lon[i].min = -lon_minutes[i]; sSidereal_time.lon[i].sec = -lon_seconds[i]; } } //only save new lon_selection when it is clear which level is selected if(select<=9 && select>4) { sSidereal_time.lon_selection=level; } #ifdef CONFIG_INFOMEM //store new longitude and time zone in information memory u16 buf[SIDEREAL_NUM_LON*sizeof(struct longitude)/2+1]; ((u8*)buf)[0]=sTime.UTCoffset; ((u8*)buf)[1]=sSidereal_time.lon_selection; memcpy(buf+1, &(sSidereal_time.lon),SIDEREAL_NUM_LON*sizeof(struct longitude)); infomem_app_replace(SIDEREAL_INFOMEM_ID,buf,SIDEREAL_NUM_LON*sizeof(struct longitude)/2+1); #endif //sync time if desired if(sync >=1) { sync_sidereal(); } else { // Disable interrupts to prevent race conditions Timer0_A1_Stop(); // Store local variables in global sidereal clock time sSidereal_time.hour = hours; sSidereal_time.minute = minutes; sSidereal_time.second = seconds; // Set clock timer for one sidereal second in the future Timer0_A1_Start(); } // Full display update is done when returning from function display_symbol(LCD_SYMB_AM, SEG_OFF); display_symbol(LCD_SYMB_ARROW_UP, SEG_OFF); display_symbol(LCD_SYMB_ARROW_DOWN, SEG_OFF); display_symbol(LCD_UNIT_L1_DEGREE, SEG_OFF); break; } switch (select) { case 0: // Heart Symbol to switch to longitude settings // Display HH:MM (LINE1) and As .SS (LINE2) str = _itoa(hours, 2, 0); display_chars(LCD_SEG_L1_3_2, str, SEG_ON); display_symbol(LCD_SEG_L1_COL, SEG_ON); str = _itoa(minutes, 2, 0); display_chars(LCD_SEG_L1_1_0, str, SEG_ON); str = _itoa(seconds, 2, 0); display_chars(LCD_SEG_L2_1_0, str, SEG_ON); display_symbol(LCD_SEG_L2_DP, SEG_ON); str = _itoa(sync,1,0); display_char(LCD_SEG_L2_3, *str, SEG_ON); display_char(LCD_SEG_L2_4, 'A', SEG_ON); set_value(&heart, 0, 0, -1, 1, SETVALUE_DISPLAY_SYMBOL + SETVALUE_NEXT_VALUE, LCD_ICON_HEART, display_value1); select =1; break; case 1: // Set Automatic Sync setings set_value(&sync, 1, 0, 0, 2, SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L2_3, display_value1); select =2; break; case 2: // Set hours set_value(&hours, 2, 0, 0, 23, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L1_3_2, display_hours_12_or_24); select = 3; break; case 3: // Set minutes set_value(&minutes, 2, 0, 0, 59, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L1_1_0, display_value1); select = 4; break; case 4: // Set seconds set_value(&seconds, 2, 0, 0, 59, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L2_1_0, display_value1); select = 0; break; /*=============================================*/ case 5: // Heart Symbol to switch to time settings or UTC offset //display current level at free digit next to the degrees str = _itoa(level+1, 1, 0); display_chars(LCD_SEG_L1_0, str, SEG_ON); str = _itoa(lon_degrees[level], 3, 0); display_chars(LCD_SEG_L1_3_1, str, SEG_ON); display_symbol(LCD_UNIT_L1_DEGREE, SEG_ON); str = _itoa(lon_minutes[level], 2, 0); display_chars(LCD_SEG_L2_4_3, str, SEG_ON); str = _itoa(lon_seconds[level], 2, 0); display_chars(LCD_SEG_L2_1_0, str, SEG_ON); display_symbol(LCD_SEG_L2_COL0, SEG_ON); if(direction[level] & 0x1) { display_symbol(LCD_SYMB_ARROW_UP, SEG_ON); } else { display_symbol(LCD_SYMB_ARROW_DOWN, SEG_ON); } set_value(&heart, 0, 0, -1, 1, SETVALUE_DISPLAY_SYMBOL + SETVALUE_NEXT_VALUE, LCD_ICON_HEART, display_value1); select =6; break; case 6: // Set orientation set_value(direction+level, 0, 0, 0, 1, SETVALUE_ROLLOVER_VALUE + SETVALUE_NEXT_VALUE + SETVALUE_SWITCH_ARROWS, 0, display_value1); select = 7; break; case 7: // Set degrees set_value(lon_degrees+level, 3, 0, 0, 180, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L1_3_1, display_value1); select = 8; break; case 8: // Set minutes set_value(lon_minutes+level, 2, 0, 0, 59, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L2_4_3, display_value1); select = 9; break; case 9: // Set seconds set_value(lon_seconds+level, 2, 0, 0, 59, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE, LCD_SEG_L2_1_0, display_value1); select = 5; break; /*=============================================*/ case 10: // Heart Symbol to switch to longitude settings if(UTCoffset >= 0) { str = _itoa(UTCoffset, 3, 0); if(UTCoffset>0) { display_symbol(LCD_SYMB_ARROW_UP, SEG_ON); } } else { str = _itoa( - UTCoffset, 3, 0); display_symbol(LCD_SYMB_ARROW_DOWN, SEG_ON); } display_chars(LCD_SEG_L1_3_1, str, SEG_ON); display_symbol(LCD_SEG_L1_DP1,SEG_ON); memcpy(str,"UTC",3); display_chars(LCD_SEG_L2_4_2, str, SEG_ON); set_value(&heart, 0, 0, -1, 1, SETVALUE_DISPLAY_SYMBOL + SETVALUE_NEXT_VALUE, LCD_ICON_HEART, display_value1); select =11; break; case 11: // Set UTC OFFSET set_value(&UTCoffset, 3, 0, -120, 120, SETVALUE_ROLLOVER_VALUE + SETVALUE_DISPLAY_VALUE + SETVALUE_NEXT_VALUE + SETVALUE_DISPLAY_ARROWS + SETVALUE_STEP_FIFE, LCD_SEG_L1_3_1, display_value1); select = 10; break; } } // Clear button flags button.all_flags = 0; }
void display_nl() { display_char('\r'); display_char('\n'); }
//***************************************************************************** // // This function reads a line of text from the player. // //***************************************************************************** int input_line(int buflen, char *buffer, int timeout, int *read_size) { int iRow, iColumn; long lChar; // // Loop forever. This loop will be explicitly when appropriate. // while(1) { // // Read a character. // lChar = input_character(timeout); // // If the ZIP interpreter has been halted, then return immediately. // if(halt) { return('\n'); } // // See if a backsapce or delete character was read. // if((lChar == '\b') || (lChar == 0x7f)) { // // See if there are any characters in the buffer. // if(*read_size != 0) { // // Decrement the number of characters in the buffer. // (*read_size)--; // // Get the cursor position. // get_cursor_position(&iRow, &iColumn); // // Move the cursor one character to the left. // move_cursor(iRow, --iColumn); // // Display a space to erase the previous character. // display_char(' '); // // Move the cursor back to the left. // move_cursor(iRow, iColumn); } } // // See if this a carriage return or newline character. // else if((lChar == '\n') || (lChar == '\r')) { // // Ignore this character if the previous character was the opposite // of the CR/LF pair. // if(((lChar == '\n') && (g_lPrevChar != '\r')) || ((lChar == '\r') && (g_lPrevChar != '\n'))) { // // Save this character as the previous character. // g_lPrevChar = lChar; // // Scroll the screen. // scroll_line(); // // Return the most recently read character. // return(lChar); } } // // See if there is space in the buffer for another character. // else if(*read_size != (buflen - 1)) { // // Save this character in the buffer. // buffer[(*read_size)++] = lChar; // // Display this character. // display_char(lChar); } // // Save this character as the previous character. // g_lPrevChar = lChar; } }
static int hex_display(EditState *s, DisplayState *ds, int offset) { int j, len, ateof; int offset1, offset2; unsigned char b; display_bol(ds); ds->style = QE_STYLE_COMMENT; display_printf(ds, -1, -1, "%08x ", offset); ateof = 0; len = s->b->total_size - offset; if (len > s->disp_width) len = s->disp_width; if (s->mode == &hex_mode) { ds->style = QE_STYLE_FUNCTION; for (j = 0; j < s->disp_width; j++) { display_char(ds, -1, -1, ' '); offset1 = offset + j; offset2 = offset1 + 1; if (j < len) { eb_read(s->b, offset1, &b, 1); display_printhex(ds, offset1, offset2, b, 2); } else { if (!ateof) { ateof = 1; } else { offset1 = offset2 = -1; } ds->cur_hex_mode = s->hex_mode; display_printf(ds, offset1, offset2, " "); ds->cur_hex_mode = 0; } if ((j & 7) == 7) display_char(ds, -1, -1, ' '); } display_char(ds, -1, -1, ' '); } ds->style = 0; display_char(ds, -1, -1, ' '); ateof = 0; for (j = 0; j < s->disp_width; j++) { offset1 = offset + j; offset2 = offset1 + 1; if (j < len) { eb_read(s->b, offset1, &b, 1); } else { b = ' '; if (!ateof) { ateof = 1; } else { offset1 = offset2 = -1; } } display_char(ds, offset1, offset2, to_disp(b)); } display_eol(ds, -1, -1); if (len >= s->disp_width) return offset + len; else return -1; }
//***************************************************************************** // // This function sets the character rendering attributes. // //***************************************************************************** void set_attribute(int attribute) { int lColumn; // // See if the text should be displayed, which means that the text window is // selected. // if(g_lDisplay) { // // Save the current cursor position. // lColumn = g_lCurColumn; // // See if the text attributes be returned to normal. // if(attribute == NORMAL) { // // Send the ANSI sequence to turn off all character attributes. // display_char('\033'); display_char('['); display_char('m'); } // // See if the text should be in reverse. // if(attribute & REVERSE) { // // Send the ANSI sequence to reverse the video. // display_char('\033'); display_char('['); display_char('7'); display_char('m'); } // // See if the text should be in bold. // if(attribute & BOLD) { // // Send the ANSI sequence to select bold characters. // display_char('\033'); display_char('['); display_char('1'); display_char('m'); } // // See if the text should be in emphasis. // if(attribute & EMPHASIS) { // // Send the ANSI sequence to select underline characters. // display_char('\033'); display_char('['); display_char('4'); display_char('m'); } // // Restore the current cursor position. // g_lCurColumn = lColumn; } }
//***************************************************************************** // // This function moves the cursor to the specified position. // //***************************************************************************** void move_cursor(int row, int col) { long lDiff; // // See if the text should be displayed, which means that the text window is // selected. // if(g_lDisplay) { // // See if the cursor should be moved to the left. // if(col < g_lCurColumn) { // // Determine how many columns to move the cursor to the left. // lDiff = g_lCurColumn - col; // // Send the ANSI sequence to move the cursor to the left. // display_char('\033'); display_char('['); if(lDiff > 9) { display_char('0' + (lDiff / 10)); } display_char('0' + (lDiff % 10)); display_char('D'); } // // See if the cursor should be moved to the right. // else if(col > g_lCurColumn) { // // Determine how many columns to move the cursor to the right. // lDiff = col - g_lCurColumn; // // Send the ANSI sequence to move the cursor to the right. // display_char('\033'); display_char('['); if(lDiff > 9) { display_char('0' + (lDiff / 10)); } display_char('0' + (lDiff % 10)); display_char('C'); } // // Save the new cursor column. // g_lCurColumn = col; } }
void display_string(char *s) { while(*s) display_char(*s++); }
// ************************************************************************************************* // @fn mx_temperature // @brief Mx button handler to set the temperature offset. // @param u8 line LINE1 // @return none // ************************************************************************************************* void mx_temperature(u8 line) { s32 temperature; s16 temperature0; volatile s16 temperature1; volatile s16 offset; // Clear display clear_display_all(); // When using English units, convert internal °C to °F before handing over value to set_value // function if (!sys.flag.use_metric_units) { // Convert global variable to local variable temperature = convert_C_to_F(sTemp.degrees); temperature0 = sTemp.degrees; } else { // Convert global variable to local variable temperature = sTemp.degrees; temperature0 = temperature; } // Loop values until all are set or user breaks set while (1) { // Idle timeout: exit without saving if (sys.flag.idle_timeout) break; // Button STAR (short): save, then exit if (button.flag.star) { // For English units, convert set °F to °C if (!sys.flag.use_metric_units) { temperature1 = convert_F_to_C(temperature); } else { temperature1 = temperature; } // New offset is difference between old and new value offset = temperature1 - temperature0; sTemp.offset += offset; // Force filter to new value sTemp.degrees = temperature1; // Set display update flag display.flag.line1_full_update = 1; break; } // Display °C or °F depending on unit system if (sys.flag.use_metric_units) display_char(LCD_SEG_L1_0, 'C', SEG_ON); else display_char(LCD_SEG_L1_0, 'F', SEG_ON); display_symbol(LCD_SEG_L1_DP1, SEG_ON); display_symbol(LCD_UNIT_L1_DEGREE, SEG_ON); // Set current temperature - offset is set when leaving function set_value(&temperature, 3, 1, -999, 999, SETVALUE_DISPLAY_VALUE + SETVALUE_DISPLAY_ARROWS, LCD_SEG_L1_3_1, display_value); } // Clear button flags button.all_flags = 0; }
//* ************************************************************************************************ /// @fn display_temperature(void) /// @brief Common display routine for metric and English units. /// @return none //* ************************************************************************************************ void display_temperature(void) { int16_t temp_inmetric; // Clear the previous value displayed display_clear(0, 1); // Display '°' and '.' display_temp_symbols(1); // Display the proper metric unit #if CONFIG_TEMPERATURE_METRIC == TEMPERATURE_DEGREES_C display_char(0, LCD_SEG_L1_0, 'C', SEG_ON); #endif #if CONFIG_TEMPERATURE_METRIC == TEMPERATURE_DEGREES_F display_char(0, LCD_SEG_L1_0, 'F', SEG_ON); #endif #if CONFIG_TEMPERATURE_METRIC == TEMPERATURE_DEGREES_BOTH if (temp_display_metric == TEMPERATURE_DEGREES_C) { display_char(0, LCD_SEG_L1_0, 'C', SEG_ON); } else { display_char(0, LCD_SEG_L1_0, 'F', SEG_ON); } #endif // Get the right temperature in the defined metric #if CONFIG_TEMPERATURE_METRIC == TEMPERATURE_DEGREES_C temperature_get_C(&temp_inmetric); #endif #if CONFIG_TEMPERATURE_METRIC == TEMPERATURE_DEGREES_F temperature_get_F(&temp_inmetric); #endif #if CONFIG_TEMPERATURE_METRIC == TEMPERATURE_DEGREES_BOTH if(temp_display_metric == TEMPERATURE_DEGREES_C) { temperature_get_C(&temp_inmetric); } else { temperature_get_F(&temp_inmetric); } #endif // Indicate temperature sign through arrow up/down icon if (temp_inmetric < 0) { // Convert negative to positive number temp_inmetric = ~temp_inmetric; display_symbol(0, LCD_SYMB_ARROW_UP, SEG_OFF); display_symbol(0, LCD_SYMB_ARROW_DOWN, SEG_ON); } else { // Temperature is >= 0 display_symbol(0, LCD_SYMB_ARROW_UP, SEG_ON); display_symbol(0, LCD_SYMB_ARROW_DOWN, SEG_OFF); } // Display result in xx.x format display_chars(0, LCD_SEG_L1_3_1, _sprintf("%2s", temp_inmetric), SEG_ON); }
// ************************************************************************************************* // @fn display_temperature // @brief Common display routine for metric and English units. // @param u8 line LINE1 // u8 update DISPLAY_LINE_UPDATE_FULL, DISPLAY_LINE_CLEAR // @return none // ************************************************************************************************* void display_temperature(u8 line, u8 update) { u8 *str; s16 temperature; // Redraw whole screen if (update == DISPLAY_LINE_UPDATE_FULL) { // Menu item is visible sTemp.state = MENU_ITEM_VISIBLE; // Display °C / °F display_symbol(LCD_SEG_L1_DP1, SEG_ON); display_symbol(LCD_UNIT_L1_DEGREE, SEG_ON); if (sys.flag.use_metric_units) display_char(LCD_SEG_L1_0, 'C', SEG_ON); else display_char(LCD_SEG_L1_0, 'F', SEG_ON); // Perform one temperature measurement with disabled filter temperature_measurement(FILTER_OFF); // Display temperature display_temperature(LINE1, DISPLAY_LINE_UPDATE_PARTIAL); } else if (update == DISPLAY_LINE_UPDATE_PARTIAL) { // When using English units, convert °C to °F (temp*1.8+32) if (!sys.flag.use_metric_units) { temperature = convert_C_to_F(sTemp.degrees); } else { temperature = sTemp.degrees; } // Indicate temperature sign through arrow up/down icon if (temperature < 0) { // Convert negative to positive number temperature = ~temperature; temperature += 1; display_symbol(LCD_SYMB_ARROW_UP, SEG_OFF); display_symbol(LCD_SYMB_ARROW_DOWN, SEG_ON); } else // Temperature is >= 0 { display_symbol(LCD_SYMB_ARROW_UP, SEG_ON); display_symbol(LCD_SYMB_ARROW_DOWN, SEG_OFF); } // Limit min/max temperature to +/- 99.9 °C / °F if (temperature > 999) temperature = 999; // Display result in xx.x format str = int_to_array(temperature, 3, 1); display_chars(LCD_SEG_L1_3_1, str, SEG_ON); } else if (update == DISPLAY_LINE_CLEAR) { // Menu item is not visible sTemp.state = MENU_ITEM_NOT_VISIBLE; // Clean up function-specific segments before leaving function display_symbol(LCD_SYMB_ARROW_UP, SEG_OFF); display_symbol(LCD_SYMB_ARROW_DOWN, SEG_OFF); display_symbol(LCD_UNIT_L1_DEGREE, SEG_OFF); display_symbol(LCD_SEG_L1_DP1, SEG_OFF); } }
/* Output to TFT display- - could later add option to write to serial port or log file */ void putchar(char c) { display_char(c); }