190 { |
190 { |
191 { 0x00, 0xF, 0x0, 0, 0, 0x01, MAX_BUFF, 245, Mono19x27}, // main display |
191 { 0x00, 0xF, 0x0, 0, 0, 0x01, MAX_BUFF, 245, Mono19x27}, // main display |
192 { 0x0C, 0xF, 0x0,204, 38, 0x01, 3, 45, Mono15x22}, // channels display |
192 { 0x0C, 0xF, 0x0,204, 38, 0x01, 3, 45, Mono15x22}, // channels display |
193 // { 0x01, 0xF, 0x0, 0, 0, 0x80, MAX_BUFF, 0, Terminal6x8}, |
193 // { 0x01, 0xF, 0x0, 0, 0, 0x80, MAX_BUFF, 0, Terminal6x8}, |
194 // { 0x02, 0xF, 0x0, 0, 0, 0x80, MAX_BUFF, 0, Terminal6x8}, |
194 // { 0x02, 0xF, 0x0, 0, 0, 0x80, MAX_BUFF, 0, Terminal6x8}, |
195 { 0x0A, 0xF, 0x0, 0, 57, 0x0C, 4, 0, Terminal6x8}, // flags + bits |
195 { 0x0A, 0xF, 0x0, 0, 57, 0x08, 4, 0, Terminal6x8}, // flags + bits |
196 // { 0xFF, 0xF, 0x0, 0, 0, 0x80, MAX_BUFF, 0, Terminal6x8}, |
196 // { 0xFF, 0xF, 0x0, 0, 0, 0x80, MAX_BUFF, 0, Terminal6x8}, |
197 }; |
197 }; |
198 |
198 |
199 // 9x10 |
199 // 9x10 |
200 const unsigned char icon_alarm[] __attribute__((aligned (2))) = |
200 const unsigned char icon_alarm[] __attribute__((aligned (2))) = |
248 { |
248 { |
249 // flag, zone, x0, y0, msg, icon |
249 // flag, zone, x0, y0, msg, icon |
250 // right-side icons area |
250 // right-side icons area |
251 { 0x00, 0x02, 0, 0, NULL, icon_alarm}, // F1.0 |
251 { 0x00, 0x02, 0, 0, NULL, icon_alarm}, // F1.0 |
252 { 0x01, 0x02, 0, 11, NULL, icon_curve}, // F1.1 |
252 { 0x01, 0x02, 0, 11, NULL, icon_curve}, // F1.1 |
|
253 //{ 0x14, 0x02, 0, 0, "4W"}, // F2.4 |
|
254 //{ 0x15, 0x02, 0, 8, "OC"}, // F2.5 |
|
255 |
253 // F1.2 == Channel frame |
256 // F1.2 == Channel frame |
254 { 0x03, 0x04, 1, 2, "Channel"}, // F1.3 |
257 { 0x03, 0x04, 1, 2, "Channel"}, // F1.3 |
255 // F1.7 == Alarm frame |
258 // F1.7 == Alarm frame |
256 |
259 |
257 // col 1 |
260 // col 1 |
259 { 0x33, 0x10, 0, 8, "VIEW"}, // F4.3 |
262 { 0x33, 0x10, 0, 8, "VIEW"}, // F4.3 |
260 { 0x35, 0x10, 0, 16, "SCAN"}, // F4.5 |
263 { 0x35, 0x10, 0, 16, "SCAN"}, // F4.5 |
261 |
264 |
262 //col 2 |
265 //col 2 |
263 { 0x32, 0x20, 0, 0, "*"}, // F4.2 |
266 { 0x32, 0x20, 0, 0, "*"}, // F4.2 |
264 { 0x36, 0x20, 0, 8, "CFG"}, // F4.6 |
267 { 0x36, 0x20, 0, 8, "CONFIG"}, // F4.6 |
265 { 0x27, 0x20, 0, 16, "ERR"}, // F3.7 |
268 { 0x27, 0x20, 0, 16, "ERROR"}, // F3.7 |
266 |
269 |
267 // col 3 |
270 // col 3 |
268 { 0x41, 0x040, 0, 0, "ADRS"}, // F4.1 |
271 { 0x41, 0x040, 0, 0, "ADRS"}, // F4.1 |
269 { 0x40, 0x040, 0, 8, "RMT"}, // F4.0 |
272 { 0x40, 0x040, 0, 8, "RMT"}, // F4.0 |
270 |
273 |
276 |
279 |
277 |
280 |
278 // col 5 |
281 // col 5 |
279 { 0x14, 0x100, 0, 0, "4W"}, // F2.4 |
282 { 0x14, 0x100, 0, 0, "4W"}, // F2.4 |
280 { 0x15, 0x100, 0, 8, "OC"}, // F2.5 |
283 { 0x15, 0x100, 0, 8, "OC"}, // F2.5 |
281 { 0x22, 0x100, 0, 16, "LST"}, // F3.2 |
284 { 0x22, 0x100, 0, 16, "LAST"}, // F3.2 |
282 { 0x21, 0x100, 0, 16, "MIN"}, // F3.1 |
285 { 0x21, 0x100, 0, 16, "MIN"}, // F3.1 |
283 { 0x20, 0x100, 0, 16, "MAX"}, // F3.0 |
286 { 0x20, 0x100, 0, 16, "MAX"}, // F3.0 |
284 { 0x17, 0x100, 0, 16, "AVG"}, // F2.7 |
287 { 0x17, 0x100, 0, 16, "AVG"}, // F2.7 |
285 |
288 |
286 { 0x05, 0x08, 0, 0, "Alarm"}, // F1.5 |
289 { 0x05, 0x08, 0, 0, "Alarm"}, // F1.5 |
292 { 0x04, 0x08, 30, 10, "L"}, // F1.4 |
295 { 0x04, 0x08, 30, 10, "L"}, // F1.4 |
293 |
296 |
294 }; |
297 }; |
295 |
298 |
296 static const FRAME zones[] = |
299 static const FRAME zones[] = |
297 { |
300 { // flag, x0, y0, x1, y1 |
298 { 0x001, 0, 0, 245, 27}, // main display area |
301 { 0x001, 0, 0, 245, 27}, // main display area |
299 { 0x002, 246, 0, 255, 27}, // right notif area |
302 { 0x002, 246, 0, 255, 27}, // right notif area |
300 { 0x004, 203, 28, 255, 54}, // channels display area |
303 { 0x004, 203, 28, 255, 54}, // channels display area |
301 { 0x008, 160, 28, 202, 54}, // alarms area |
304 { 0x008, 160, 28, 202, 54}, // alarms area |
302 { 0x010, 0, 28, 32, 54}, // flags col1 |
305 { 0x010, 0, 28, 32, 54}, // flags col1 |
303 { 0x020, 33, 28, 70, 54}, // flags col2 |
306 { 0x020, 33, 28, 70, 54}, // flags col2 |
304 { 0x040, 71, 28, 103, 54}, // flags col3 |
307 { 0x040, 71, 28, 103, 54}, // flags col3 |
305 { 0x080, 104, 28, 128, 54}, // flags col4 |
308 { 0x080, 104, 28, 128, 54}, // flags col4 |
306 { 0x100, 129, 28, 159, 54}, // flags col5 |
309 { 0x100, 129, 28, 159, 54}, // flags col5 |
307 |
310 |
308 { 0x8000, 0, 55, 255, 63}, // flags bits display area |
311 // { 0x8000, 0, 55, 255, 63}, // flags bits display area |
309 }; |
312 }; |
310 |
313 |
311 static const FRAME frames[] = |
314 static const FRAME frames[] = |
312 { |
315 { |
313 { 0x02, 203, 35, 255, 54}, // F1.2 - channel frame |
316 { 0x02, 203, 35, 255, 54}, // F1.2 - channel frame |
359 |
363 |
360 //printf("Attaching Led 1: %d\n", LED1); |
364 //printf("Attaching Led 1: %d\n", LED1); |
361 //blinker.attach(callback(timeout_h), 0.5f); |
365 //blinker.attach(callback(timeout_h), 0.5f); |
362 |
366 |
363 hp = NULL; |
367 hp = NULL; |
|
368 printf("Serial communication pins\r\n"); |
|
369 printf(" USBRX=%d\r\n", USBRX); |
|
370 printf(" USBTX=%d\r\n", USBTX); |
|
371 |
364 printf("Setup HP communication pins\r\n"); |
372 printf("Setup HP communication pins\r\n"); |
365 printf(" HP_RX=%d\r\n", HP_RX); |
373 printf(" HP_RX=%d\r\n", HP_RX); |
366 DigitalIn(HP_RX).mode(PullDown); |
374 DigitalIn(HP_RX).mode(PullDown); |
367 printf(" HP_TX=%d\r\n", HP_TX); |
375 printf(" HP_TX=%d\r\n", HP_TX); |
368 DigitalOut(HP_TX).write(1); |
376 DigitalOut(HP_TX).write(1); |
386 kpad->attach(&kp_cb, &kr_cb); |
394 kpad->attach(&kp_cb, &kr_cb); |
387 printf(" start Keypad\r\n"); |
395 printf(" start Keypad\r\n"); |
388 kpad->start(); |
396 kpad->start(); |
389 |
397 |
390 printf("Setup OLED display\r\n"); |
398 printf("Setup OLED display\r\n"); |
391 splashscreen = true; |
|
392 // init the LCD |
399 // init the LCD |
393 printf(" DSP_MOSI=%d\r\n", DSP_MOSI); |
400 printf(" DSP_MOSI=%d\r\n", DSP_MOSI); |
394 printf(" DSP_MISO=%d\r\n", DSP_MISO); |
401 printf(" DSP_MISO=%d\r\n", DSP_MISO); |
395 printf(" DSP_SCLK=%d\r\n", DSP_SCLK); |
402 printf(" DSP_SCLK=%d\r\n", DSP_SCLK); |
396 printf(" DSP_CS=%d\r\n", DSP_CS); |
403 printf(" DSP_CS=%d\r\n", DSP_CS); |
424 dsp->copy_to_lcd(); |
431 dsp->copy_to_lcd(); |
425 |
432 |
426 printf("Starting LCD thread\r\n"); |
433 printf("Starting LCD thread\r\n"); |
427 tdsp.start(©_to_lcd); |
434 tdsp.start(©_to_lcd); |
428 |
435 |
429 //printf("Starting Event thread\r\n"); |
436 printf("Starting Event thread\r\n"); |
430 //tloop.start(&loop); |
437 tloop.start(&loop); |
|
438 |
|
439 dsp->clrbuff(); |
|
440 show(0x00, "HH:MM:\tSS\t:mmmm", 15); // main dsp |
|
441 show(0x0C, "888", 3); // channel dsp |
|
442 show(0x0A, "\xFF\xFF\xFF\xFF", 4); // all flags |
431 |
443 |
432 printf("Attaching timers\r\n"); |
444 printf("Attaching timers\r\n"); |
|
445 splashscreen = true; |
433 splashscreen_timer.attach(callback(&end_splashscreen), 2); |
446 splashscreen_timer.attach(callback(&end_splashscreen), 2); |
434 rst.fall(&reset_irq); |
447 rst.fall(&reset_irq); |
435 |
448 |
436 printf("SETUP DONE\r\n"); |
449 printf("SETUP DONE\r\n"); |
437 } |
450 } |
438 |
451 |
439 void end_splashscreen(void) |
452 void end_splashscreen(void) |
440 { |
453 { |
441 printf("End of splash screen\r\n"); |
454 printf("End of splash screen CB\r\n"); |
|
455 //dsp->cls(); |
442 splashscreen = false; |
456 splashscreen = false; |
443 } |
457 } |
444 |
458 |
445 void reset_irq(void) |
459 void reset_irq(void) |
446 { |
460 { |
515 dsp->set_font((unsigned char*) table[i].font); |
537 dsp->set_font((unsigned char*) table[i].font); |
516 oldv = table[i].buffer; |
538 oldv = table[i].buffer; |
517 |
539 |
518 dsp->locate(table[i].x0, table[i].y0); |
540 dsp->locate(table[i].x0, table[i].y0); |
519 |
541 |
520 if (table[i].fmt & 0x01 ) { |
542 if (table[i].fmt & 0x01 ) |
521 if (strncmp(oldv, txt, table[i].maxsize) != 0) { |
543 { |
522 // ascii |
544 if (strncmp(oldv, txt, table[i].maxsize) != 0) |
523 if (table[i].width > 0) |
545 { |
524 dsp->fillrect(table[i].x0, table[i].y0, table[i].x0 + table[i].width, table[i].y0 + table[i].font[2], bgcolor); |
546 // ascii |
525 for (uint8_t k=0; ;k++) { |
547 if (table[i].width > 0) |
526 if (txt[k] == 0x00) |
548 dsp->fillrect(table[i].x0, |
527 { |
549 table[i].y0, |
528 dsp->printf(txt); |
550 table[i].x0 + table[i].width, |
529 break; |
551 table[i].y0 + table[i].font[2], |
530 } |
552 bgcolor); |
531 if (txt[k] == 0x09) { // \t is a special char for 'unselected' display value |
553 for (uint8_t k=0; ;k++) |
532 txt[k] = 0x00; |
554 { |
533 dsp->printf(txt); |
555 if (txtp[k] == 0x00) |
534 |
556 { |
535 if (fgcolor == table[i].color) |
557 dsp->printf(txtp); |
536 fgcolor /= 2; |
558 break; |
537 else |
559 } |
538 fgcolor = table[i].color; |
560 if (txtp[k] == 0x09) |
539 dsp->foreground(fgcolor); |
561 { // \t is a special char for 'unselected' display value |
540 txt = &(txt[k+1]); |
562 txtp[k] = 0x00; |
541 k = 0; |
563 dsp->printf(txtp); |
542 } |
564 |
543 } |
565 if (fgcolor == table[i].color) |
544 if (cmd == 0x00) // main area |
566 fgcolor /= 2; |
545 must_refresh |= 0x01; |
567 else |
546 if (cmd == 0x0C) // channels area |
568 fgcolor = table[i].color; |
547 must_refresh |= 0x04; |
569 dsp->foreground(fgcolor); |
548 } |
570 txtp = &(txtp[k+1]); |
|
571 k = 0; |
|
572 } |
|
573 } |
|
574 if (cmd == 0x00) // main area |
|
575 must_refresh |= 0x01; |
|
576 if (cmd == 0x0C) // channels area |
|
577 must_refresh |= 0x04; |
|
578 } |
549 } |
579 } |
550 /* |
580 /* |
551 if (table[i].fmt & 0x02 ) { |
581 if (table[i].fmt & 0x02 ) { |
552 // hex |
582 // hex |
553 for (uint8_t j=0;; j++) { |
583 for (uint8_t j=0;; j++) { |
557 } |
587 } |
558 for (uint8_t j=3*strlen(txt); j<table[i].maxsize; j++) |
588 for (uint8_t j=3*strlen(txt); j<table[i].maxsize; j++) |
559 dsp->printf(" "); |
589 dsp->printf(" "); |
560 } |
590 } |
561 */ |
591 */ |
562 if (table[i].fmt & 0x04 ) { |
592 if (table[i].fmt & 0x08 ) |
563 // binary |
593 { |
564 dsp->foreground(fgcolor); |
594 // flags |
565 dsp->printf(" ["); |
595 for (uint8_t j=0; j<max(nchar, table[i].maxsize) ; j++) |
566 for (uint8_t j=0; j<max(nchar, table[i].maxsize) ; j++) { |
596 { |
567 if (j>0) { |
597 for (uint8_t k=0; k<8; k++) |
568 dsp->foreground(fgcolor); |
598 { |
569 dsp->printf(" | "); |
599 if (1) |
570 } |
600 { //(txt[j] & (1 << k) ) != (oldv[j] & (1 << k))) { |
571 for (uint8_t k=0; k<8; k++) { |
601 if (txtp[j] & (1 << k)) |
572 if (txt[j] & (1 << (7-k))) |
602 dsp->foreground(fgcolor); |
573 dsp->foreground(fgcolor); |
603 else |
574 else |
604 dsp->foreground(bgcolor); |
575 dsp->foreground(bgcolor); |
|
576 dsp->printf("%d", (8-k)); |
|
577 } |
|
578 } |
|
579 dsp->foreground(fgcolor); |
|
580 dsp->printf("]"); |
|
581 must_refresh |= 0x8000; |
|
582 } |
|
583 |
|
584 if (table[i].fmt & 0x08 ) { |
|
585 // flags |
|
586 for (uint8_t j=0; j<max(nchar, table[i].maxsize) ; j++) { |
|
587 for (uint8_t k=0; k<8; k++) { |
|
588 if (1) {//(txt[j] & (1 << k) ) != (oldv[j] & (1 << k))) { |
|
589 |
|
590 if (txt[j] & (1 << k)) |
|
591 dsp->foreground(fgcolor); |
|
592 else |
|
593 dsp->foreground(bgcolor); |
|
594 |
605 |
595 /* |
606 /* |
596 for (uint8_t l=0; |
607 for (uint8_t l=0; |
597 l<(sizeof(frames)/sizeof(frames[0])); ++l) { |
608 l<(sizeof(frames)/sizeof(frames[0])); ++l) { |
598 if (frames[l].flag & ((j<<4) + k)) |
609 if (frames[l].flag & ((j<<4) + k)) |
605 bgcolor); |
616 bgcolor); |
606 |
617 |
607 } |
618 } |
608 */ |
619 */ |
609 |
620 |
610 for (uint8_t l=0; |
621 for (uint8_t l=0; |
611 l<(sizeof(flags)/sizeof(flags[0])); ++l) { |
622 l<(sizeof(flags)/sizeof(flags[0])); ++l) |
612 if (flags[l].flag == ((j<<4) + k)) { |
623 { |
613 for (uint8_t m=0; m<(sizeof(zones)/sizeof(zones[0])); m++) { |
624 if (flags[l].flag == ((j<<4) + k)) { |
614 if (flags[l].zone == zones[m].flag) { |
625 for (uint8_t m=0; m<(sizeof(zones)/sizeof(zones[0])); m++) |
615 if (flags[l].msg != NULL) { // a string |
626 { |
616 dsp->locate(flags[l].x + zones[m].x0, |
627 if (flags[l].zone == zones[m].flag) { |
617 flags[l].y + zones[m].y0); |
628 if (flags[l].msg != NULL) |
618 dsp->printf(flags[l].msg);} |
629 { // a string |
619 else { // an icon |
630 dsp->locate(flags[l].x + zones[m].x0, |
620 Bitmap_s pic = {9, 10, 2, (char*) flags[l].icon}; |
631 flags[l].y + zones[m].y0); |
621 dsp->Bitmap_BW(pic, |
632 dsp->printf(flags[l].msg);} |
622 flags[l].x + zones[m].x0, |
633 else |
623 flags[l].y + zones[m].y0); |
634 { // an icon |
624 } |
635 Bitmap_s pic = {9, 10, 2, (char*) flags[l].icon}; |
625 must_refresh |= zones[m].flag; |
636 dsp->Bitmap_BW(pic, |
626 break; |
637 flags[l].x + zones[m].x0, |
627 } |
638 flags[l].y + zones[m].y0); |
|
639 } |
|
640 must_refresh |= zones[m].flag; |
|
641 break; |
|
642 } |
|
643 } |
|
644 break; |
|
645 } |
|
646 } |
|
647 } |
628 } |
648 } |
629 break; |
|
630 } |
649 } |
631 } |
|
632 } |
|
633 } |
|
634 } |
|
635 } |
650 } |
636 |
651 |
637 for(uint8_t j=0; j<table[i].maxsize; j++) |
652 for(uint8_t j=0; j<table[i].maxsize; j++) |
638 oldv[j] = txt[j]; |
653 oldv[j] = txt[j]; |
639 break; |
654 break; |
640 } |
655 } |
641 } |
656 } |
642 free(txt); |
657 free(txt); |
643 //dsp->copy_to_lcd(); |
658 //dsp->copy_to_lcd(); |
644 pulse(1, false); |
659 pulse(1, false); |
|
660 } |
645 } |
661 } |
646 |
662 |
647 void test_dsp() |
663 void test_dsp() |
648 { |
664 { |
649 const FRAME *z; |
665 const FRAME *z; |
|
666 printf("TEST DSP\r\n"); |
|
667 dsp->cls(); |
|
668 printf("TEST DSP #2\r\n"); |
650 show(0x00, "8g8g8g8g8g8g8", 13); // main dsp |
669 show(0x00, "8g8g8g8g8g8g8", 13); // main dsp |
651 show(0x0C, "888", 3); // channel dsp |
670 show(0x0C, "888", 3); // channel dsp |
652 show(0x0A, "\xFF\xFF\xFF\xFF", 4); // all flags |
671 show(0x0A, "\xFF\xFF\xFF\xFF", 4); // all flags |
653 dsp->copy_to_lcd(); |
672 dsp->copy_to_lcd(); |
654 wait(3); |
673 wait(3); |
655 dsp->cls(); |
674 dsp->cls(); |
656 |
675 printf("TEST DSP #3\r\n"); |
657 |
676 |
658 for (uint8_t i=0; i<(sizeof(zones)/sizeof(zones[0])); i++) |
677 for (uint8_t i=0; i<(sizeof(zones)/sizeof(zones[0])); i++) |
659 { |
678 { |
660 z = &zones[i]; |
679 z = &zones[i]; |
661 dsp->fillrect(z->x0, z->y0, z->x1, z->y1, 4+i); |
680 dsp->fillrect(z->x0, z->y0, z->x1, z->y1, 4+i); |