2018 revision to classic DataBus AVC code.

Dependencies:   LSM303DLM Servo SerialGraphicLCD L3G4200D IncrementalEncoder SimpleShell

Committer:
shimniok
Date:
Thu Jan 03 17:50:44 2019 +0000
Revision:
42:8d99f64f5898
Parent:
41:f07bf1039ba3
Implemented uart2 bridge for testing

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shimniok 37:b8259500dbd3 1 #include "Display.h"
shimniok 37:b8259500dbd3 2 #include <string.h>
shimniok 37:b8259500dbd3 3
shimniok 37:b8259500dbd3 4 #define LCDWIDTH 21
shimniok 37:b8259500dbd3 5
shimniok 37:b8259500dbd3 6 Display::Display(PinName tx, PinName rx)
shimniok 37:b8259500dbd3 7 {
shimniok 37:b8259500dbd3 8 lcd = new SerialGraphicLCD(tx, rx);
shimniok 37:b8259500dbd3 9 lcd->clear();
shimniok 37:b8259500dbd3 10 }
shimniok 37:b8259500dbd3 11
shimniok 37:b8259500dbd3 12
shimniok 38:6fec81f85221 13 void Display::gps(GpsData d)
shimniok 37:b8259500dbd3 14 {
shimniok 38:6fec81f85221 15 lcd->pos(0,6);
shimniok 40:d3cebffe1e44 16 lcd->printf("lat: %12.7f ", d.latitude);
shimniok 38:6fec81f85221 17 lcd->pos(0,5);
shimniok 40:d3cebffe1e44 18 lcd->printf("lon: %12.7f ", d.longitude);
shimniok 38:6fec81f85221 19 lcd->pos(0,4);
shimniok 41:f07bf1039ba3 20 lcd->printf("sv:%-2d h:%-3.0f s:%-4.1f ", d.svcount, d.course, d.speed);
shimniok 37:b8259500dbd3 21 }
shimniok 37:b8259500dbd3 22
shimniok 42:8d99f64f5898 23
shimniok 37:b8259500dbd3 24 void Display::imu(SensorData d)
shimniok 37:b8259500dbd3 25 {
shimniok 42:8d99f64f5898 26 lcd->pos(0,3);
shimniok 42:8d99f64f5898 27 lcd->printf("gyr: z:%4d ", d.gyro[2]);
shimniok 42:8d99f64f5898 28 lcd->pos(0,2);
shimniok 42:8d99f64f5898 29 lcd->printf("acc: x:%4d y:%4d ", d.accel[0], d.accel[1]);
shimniok 42:8d99f64f5898 30 lcd->pos(0,1);
shimniok 42:8d99f64f5898 31 lcd->printf("mag: x:%4d y:%4d ", d.mag[0], d.mag[1]);
shimniok 37:b8259500dbd3 32 }
shimniok 37:b8259500dbd3 33
shimniok 42:8d99f64f5898 34
shimniok 42:8d99f64f5898 35 void Display::cpu(int idle)
shimniok 42:8d99f64f5898 36 {
shimniok 42:8d99f64f5898 37 lcd->pos(13,7);
shimniok 42:8d99f64f5898 38 lcd->printf("idle:%3d%%", idle);
shimniok 42:8d99f64f5898 39 }
shimniok 42:8d99f64f5898 40
shimniok 42:8d99f64f5898 41
shimniok 37:b8259500dbd3 42 void Display::status(char *s)
shimniok 37:b8259500dbd3 43 {
shimniok 37:b8259500dbd3 44 char line[LCDWIDTH+1];
shimniok 37:b8259500dbd3 45 int i;
shimniok 37:b8259500dbd3 46 int len = strlen(s);
shimniok 37:b8259500dbd3 47
shimniok 37:b8259500dbd3 48 for (i = 0; i < LCDWIDTH; i++) {
shimniok 37:b8259500dbd3 49 if (i < len) {
shimniok 37:b8259500dbd3 50 line[i] = s[i];
shimniok 37:b8259500dbd3 51 } else {
shimniok 37:b8259500dbd3 52 line[i] = ' ';
shimniok 37:b8259500dbd3 53 }
shimniok 37:b8259500dbd3 54 }
shimniok 37:b8259500dbd3 55 line[LCDWIDTH] = 0;
shimniok 37:b8259500dbd3 56
shimniok 38:6fec81f85221 57 lcd->pos(0,7);
shimniok 37:b8259500dbd3 58 // TODO: limit string length
shimniok 37:b8259500dbd3 59 lcd->printf(line);
shimniok 37:b8259500dbd3 60 }