Terminal program for MailStation devices
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Revamp statusbar drawing, draw left and right portions separately

+72 -37
+6 -1
mailstation.h
··· 172 172 extern volatile unsigned char mem0; 173 173 extern volatile unsigned char obuf[]; 174 174 extern volatile unsigned char obuf_pos; 175 - extern void update_statusbar(char *status, ...); 175 + enum { 176 + STATUSBAR_INIT, 177 + STATUSBAR_LEFT, 178 + STATUSBAR_RIGHT, 179 + }; 180 + extern void update_statusbar(short which, char *status, ...); 176 181 177 182 178 183 /* settings.s */
+66 -36
main.c
··· 27 27 unsigned char esc; 28 28 unsigned char old_modem_msr; 29 29 unsigned char old_minutes; 30 + unsigned char old_statusbar_left_len; 31 + unsigned char old_statusbar_right_len; 30 32 31 33 #define MODEM_MSR_DCD (1 << 7) 32 34 ··· 80 82 old_obuf_pos = 0; 81 83 old_modem_msr = 0; 82 84 old_minutes = 0; 85 + old_statusbar_left_len = 0; 86 + old_statusbar_right_len = 0; 83 87 debug0 = 0; 84 88 85 89 settings_read(); 86 90 clear_screen_bufs(); 87 91 clear_screen(); 88 - 89 - maybe_update_statusbar(1); 92 + update_statusbar(STATUSBAR_INIT, NULL); 90 93 91 94 /* - 1 to ignore final null byte */ 92 95 for (b = 0; b < sizeof(logo) - 1; b++) { 93 96 if (b == 0 || logo[b - 1] == '\n') { 94 97 /* center logo without wasting space in logo[] */ 95 - for (j = 0; j < 12; j++) 98 + for (j = 0; j < 14; j++) 96 99 putchar(' '); 97 100 } 98 101 99 102 putchar(logo[b]); 100 103 } 101 - 102 104 printf(" v%u\n\n", msTERM_version); 103 105 104 106 switch (source) { ··· 126 128 obuf_queue("AT\r\n"); 127 129 break; 128 130 } 131 + 132 + maybe_update_statusbar(1); 129 133 130 134 for (;;) { 131 135 process_keyboard(); ··· 174 178 } 175 179 176 180 void 177 - update_statusbar(char *status, ...) 181 + update_statusbar(short which, char *status, ...) 178 182 { 179 183 va_list args; 180 - char tstatus[255], c; 184 + char tstatus[64], c; 181 185 char *result = NULL; 182 - unsigned char x, l; 186 + unsigned char i, x, l, mx; 187 + 188 + if (which == STATUSBAR_INIT) { 189 + for (i = 0; i < LCD_COLS; i++) 190 + putchar_attr(LCD_ROWS - 1, i, ' ', ATTR_REVERSE); 191 + return; 192 + } 183 193 184 194 va_start(args, status); 185 - vsprintf(tstatus, status, args); 195 + l = vsprintf(tstatus, status, args); 186 196 va_end(args); 187 197 188 - l = strlen(tstatus); 198 + if (which == STATUSBAR_LEFT) 199 + mx = (l > old_statusbar_left_len ? l : old_statusbar_left_len); 200 + else 201 + mx = (l > old_statusbar_right_len ? l : old_statusbar_right_len); 189 202 190 - for (x = 0; x < TEXT_COLS; x++) { 191 - if (x >= l) 192 - c = ' '; 193 - else 194 - c = tstatus[x]; 203 + if (mx > LCD_COLS) 204 + mx = LCD_COLS; 205 + 206 + for (i = 0; i < mx; i++) { 207 + if (which == STATUSBAR_LEFT) { 208 + if (i >= l) 209 + c = ' '; 210 + else 211 + c = tstatus[i]; 212 + x = i; 213 + } else { 214 + if (i >= l) 215 + c = ' '; 216 + else 217 + c = tstatus[l - 1 - i]; 218 + x = LCD_COLS - 1 - i; 219 + } 195 220 196 221 putchar_attr(LCD_ROWS - 1, x, c, ATTR_REVERSE); 197 222 } 223 + 224 + if (which == STATUSBAR_LEFT) 225 + old_statusbar_left_len = l; 226 + else if (which == STATUSBAR_RIGHT) 227 + old_statusbar_right_len = l; 198 228 } 199 229 200 230 void 201 231 maybe_update_statusbar(unsigned char force) 202 232 { 203 - unsigned char s; 233 + unsigned char s = 0; 204 234 unsigned char update = 0; 205 235 206 - if (modem_curmsr & MODEM_MSR_DCD) 207 - s = 1; /* DCD set, call in progress */ 208 - else 209 - s = 0; 236 + if (source == SOURCE_MODEM) { 237 + if (modem_curmsr & MODEM_MSR_DCD) 238 + s |= (1 << 0); /* DCD set, call in progress */ 239 + } 210 240 211 - if (s != (statusbar_state & (1 << 0))) { 212 - statusbar_state ^= (1 << 0); 213 - update = 1; 241 + if (force || s != statusbar_state) { 242 + update_statusbar(STATUSBAR_LEFT, "%s%s", 243 + statusbar_state & (1 << 0) ? STATUSBAR_HANGUP : STATUSBAR_CALL, 244 + STATUSBAR_SETTINGS); 245 + 246 + statusbar_state = s; 214 247 } 215 248 216 - if ((rtcminutes != old_minutes) || force) { 249 + if (force || (rtcminutes != old_minutes)) { 217 250 old_minutes = rtcminutes; 218 - sprintf(statusbar_time, "| %5u | %02d:%02d ", 219 - setting_modem_speed, 220 - (rtc10hours * 10) + rtchours, 221 - (rtc10minutes * 10) + rtcminutes); 222 - update = 1; 223 - } 224 - 225 - if (update || force) { 226 - update_statusbar("%s%s%s %s", 227 - statusbar_state & (1 << 0) ? STATUSBAR_HANGUP : STATUSBAR_CALL, 228 - STATUSBAR_SETTINGS, 229 - STATUSBAR_BLANK, 230 - statusbar_time); 251 + if (source == SOURCE_MODEM) 252 + update_statusbar(STATUSBAR_RIGHT, "%5u | %02d:%02d ", 253 + setting_modem_speed, 254 + (rtc10hours * 10) + rtchours, 255 + (rtc10minutes * 10) + rtcminutes); 256 + else 257 + update_statusbar(STATUSBAR_RIGHT, "%02d:%02d ", 258 + (rtc10hours * 10) + rtchours, 259 + (rtc10minutes * 10) + rtcminutes); 231 260 } 232 261 } 262 + 233 263 234 264 void 235 265 process_keyboard(void)