Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: CANBuffer KS0108_fork mbed-rtos mbed CAN Addresses
Fork of REVO_Updated_Steering by
Revision 36:8544a8900884, committed 2015-01-29
- Comitter:
- tmccurbin
- Date:
- Thu Jan 29 04:27:19 2015 +0000
- Parent:
- 35:b42afc973902
- Child:
- 37:c9b9057079d9
- Commit message:
- MAJOR UPDATE; New libraries added for screens, buffers, & CAN addresses.; CAN data displays in real-time.
Changed in this revision
--- a/Arial10.h Sat Nov 22 22:24:53 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,154 +0,0 @@
-
-/*
- *
- * File Name : Arial10.h
- * Date : 15.11.2014
- * Font size in bytes : 3801
- * Font width : 10
- * Font height : 9
- * Font first char : 32
- * Font last char : 128
- * Font used chars : 96
- *
- * The font data are defined as
- *
- * struct _FONT_ {
- * uint16_t font_Size_in_Bytes_over_all_included_Size_it_self;
- * uint8_t font_Width_in_Pixel_for_fixed_drawing;
- * uint8_t font_Height_in_Pixel_for_all_characters;
- * unit8_t font_First_Char;
- * uint8_t font_Char_Count;
- *
- * uint8_t font_Char_Widths[font_Last_Char - font_First_Char +1];
- * // for each character the separate width in pixels,
- * // characters < 128 have an implicit virtual right empty row
- *
- * uint8_t font_data[];
- * // bit field of all characters
- */
-
-#ifndef ARIAL10_H
-#define ARIAL10_H
-
-#define ARIAL10_WIDTH 10
-#define ARIAL10_HEIGHT 9
-
-unsigned int Arial10[] = {
- 0x0E, 0xD9, // size
- 0x0A, // width
- 0x09, // height
- 0x20, // first char
- 0x60, // char count
-
- // char widths
- 0x00, 0x01, 0x03, 0x05, 0x05, 0x07, 0x07, 0x01, 0x03, 0x03,
- 0x03, 0x05, 0x01, 0x02, 0x01, 0x03, 0x05, 0x03, 0x05, 0x05,
- 0x06, 0x05, 0x05, 0x05, 0x05, 0x05, 0x01, 0x01, 0x04, 0x05,
- 0x04, 0x06, 0x09, 0x07, 0x05, 0x05, 0x05, 0x05, 0x04, 0x06,
- 0x05, 0x01, 0x04, 0x06, 0x05, 0x07, 0x05, 0x06, 0x05, 0x06,
- 0x05, 0x05, 0x05, 0x05, 0x07, 0x09, 0x07, 0x07, 0x06, 0x02,
- 0x03, 0x02, 0x05, 0x06, 0x02, 0x04, 0x04, 0x04, 0x04, 0x04,
- 0x03, 0x04, 0x04, 0x01, 0x02, 0x04, 0x01, 0x07, 0x04, 0x04,
- 0x04, 0x04, 0x02, 0x04, 0x03, 0x04, 0x05, 0x07, 0x05, 0x05,
- 0x05, 0x03, 0x01, 0x03, 0x05, 0x05,
-
- // font data
- 0x5F, 0x00, // 33
- 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, // 34
- 0x74, 0x1E, 0x75, 0x1E, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, // 35
- 0x26, 0x4D, 0xFF, 0x49, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, // 36
- 0x06, 0x09, 0x66, 0x18, 0x36, 0x49, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 37
- 0x30, 0x4A, 0x4D, 0x55, 0x23, 0x70, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 38
- 0x07, 0x00, // 39
- 0x7C, 0x82, 0x01, 0x00, 0x00, 0x80, // 40
- 0x01, 0x82, 0x7C, 0x80, 0x00, 0x00, // 41
- 0x05, 0x03, 0x05, 0x00, 0x00, 0x00, // 42
- 0x08, 0x08, 0x3E, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, // 43
- 0xC0, 0x00, // 44
- 0x10, 0x10, 0x00, 0x00, // 45
- 0x40, 0x00, // 46
- 0x60, 0x1C, 0x03, 0x00, 0x00, 0x00, // 47
- 0x3E, 0x41, 0x41, 0x41, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, // 48
- 0x04, 0x02, 0x7F, 0x00, 0x00, 0x00, // 49
- 0x42, 0x61, 0x51, 0x49, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, // 50
- 0x22, 0x41, 0x49, 0x49, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, // 51
- 0x18, 0x14, 0x12, 0x11, 0x7F, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 52
- 0x2C, 0x47, 0x45, 0x45, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, // 53
- 0x3E, 0x45, 0x45, 0x45, 0x3A, 0x00, 0x00, 0x00, 0x00, 0x00, // 54
- 0x01, 0x61, 0x19, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, // 55
- 0x36, 0x49, 0x49, 0x49, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, // 56
- 0x2E, 0x51, 0x51, 0x51, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, // 57
- 0x44, 0x00, // 58
- 0xC4, 0x00, // 59
- 0x08, 0x14, 0x14, 0x22, 0x00, 0x00, 0x00, 0x00, // 60
- 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, // 61
- 0x22, 0x14, 0x14, 0x08, 0x00, 0x00, 0x00, 0x00, // 62
- 0x02, 0x01, 0x01, 0x59, 0x09, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 63
- 0x78, 0x86, 0x3A, 0x45, 0x45, 0x79, 0x4D, 0xA2, 0x9C, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, // 64
- 0x40, 0x38, 0x16, 0x11, 0x16, 0x38, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 65
- 0x7F, 0x49, 0x49, 0x49, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, // 66
- 0x3E, 0x41, 0x41, 0x41, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, // 67
- 0x7F, 0x41, 0x41, 0x22, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, // 68
- 0x7F, 0x49, 0x49, 0x49, 0x49, 0x00, 0x00, 0x00, 0x00, 0x00, // 69
- 0x7F, 0x09, 0x09, 0x01, 0x00, 0x00, 0x00, 0x00, // 70
- 0x1C, 0x22, 0x41, 0x49, 0x2A, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 71
- 0x7F, 0x08, 0x08, 0x08, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, // 72
- 0x7F, 0x00, // 73
- 0x60, 0x40, 0x40, 0x3F, 0x00, 0x00, 0x00, 0x00, // 74
- 0x7F, 0x10, 0x08, 0x14, 0x22, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 75
- 0x7F, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, // 76
- 0x7F, 0x06, 0x38, 0x40, 0x38, 0x06, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 77
- 0x7F, 0x06, 0x08, 0x30, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, // 78
- 0x3E, 0x41, 0x41, 0x41, 0x41, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 79
- 0x7F, 0x09, 0x09, 0x09, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, // 80
- 0x3E, 0x41, 0x41, 0x61, 0x61, 0x5E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 81
- 0x7F, 0x09, 0x09, 0x19, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, // 82
- 0x26, 0x49, 0x49, 0x49, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, // 83
- 0x01, 0x01, 0x7F, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, // 84
- 0x3F, 0x40, 0x40, 0x40, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, // 85
- 0x01, 0x0E, 0x30, 0x40, 0x30, 0x0E, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 86
- 0x03, 0x3C, 0x40, 0x3E, 0x01, 0x3E, 0x40, 0x3C, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 87
- 0x40, 0x21, 0x12, 0x0C, 0x12, 0x21, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 88
- 0x01, 0x02, 0x04, 0x78, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 89
- 0x61, 0x51, 0x49, 0x45, 0x43, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 90
- 0xFF, 0x01, 0x80, 0x80, // 91
- 0x03, 0x1C, 0x60, 0x00, 0x00, 0x00, // 92
- 0x01, 0xFF, 0x80, 0x80, // 93
- 0x08, 0x06, 0x01, 0x06, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, // 94
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // 95
- 0x01, 0x02, 0x00, 0x00, // 96
- 0x60, 0x54, 0x54, 0x7C, 0x00, 0x00, 0x00, 0x00, // 97
- 0x7F, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, 0x00, // 98
- 0x38, 0x44, 0x44, 0x28, 0x00, 0x00, 0x00, 0x00, // 99
- 0x38, 0x44, 0x44, 0x7F, 0x00, 0x00, 0x00, 0x00, // 100
- 0x38, 0x54, 0x54, 0x58, 0x00, 0x00, 0x00, 0x00, // 101
- 0x04, 0x7E, 0x05, 0x00, 0x00, 0x00, // 102
- 0xB8, 0x44, 0x44, 0xFC, 0x00, 0x80, 0x80, 0x00, // 103
- 0x7F, 0x04, 0x04, 0x78, 0x00, 0x00, 0x00, 0x00, // 104
- 0x7D, 0x00, // 105
- 0x00, 0xFD, 0x80, 0x00, // 106
- 0x7F, 0x10, 0x38, 0x44, 0x00, 0x00, 0x00, 0x00, // 107
- 0x7F, 0x00, // 108
- 0x7C, 0x04, 0x04, 0x7C, 0x04, 0x04, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 109
- 0x7C, 0x04, 0x04, 0x78, 0x00, 0x00, 0x00, 0x00, // 110
- 0x38, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, 0x00, // 111
- 0xFC, 0x44, 0x44, 0x38, 0x80, 0x00, 0x00, 0x00, // 112
- 0x38, 0x44, 0x44, 0xFC, 0x00, 0x00, 0x00, 0x80, // 113
- 0x7C, 0x04, 0x00, 0x00, // 114
- 0x48, 0x54, 0x54, 0x24, 0x00, 0x00, 0x00, 0x00, // 115
- 0x04, 0x7F, 0x44, 0x00, 0x00, 0x00, // 116
- 0x3C, 0x40, 0x40, 0x7C, 0x00, 0x00, 0x00, 0x00, // 117
- 0x04, 0x38, 0x40, 0x38, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, // 118
- 0x3C, 0x40, 0x38, 0x04, 0x38, 0x40, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 119
- 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, // 120
- 0x04, 0x38, 0xC0, 0x38, 0x04, 0x00, 0x80, 0x00, 0x00, 0x00, // 121
- 0x44, 0x64, 0x54, 0x4C, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, // 122
- 0x10, 0xEF, 0x01, 0x00, 0x80, 0x80, // 123
- 0xFF, 0x80, // 124
- 0x01, 0xEF, 0x10, 0x80, 0x80, 0x00, // 125
- 0x18, 0x08, 0x18, 0x10, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, // 126
- 0x7E, 0x42, 0x42, 0x42, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00 // 127
-
-};
-
-#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Buffers.h Thu Jan 29 04:27:19 2015 +0000 @@ -0,0 +1,55 @@ +#define _size 10 + +// Battery +char BigBatLifeBuffer[_size]; +char SmallBatLifeBuffer[_size]; +char BigBatVoltBuffer[_size]; +char BigBatPowerBuffer[_size]; +char BigBatCurrentBuffer[_size]; +char AvgBatTBuffer[_size]; +char MaxBatTBuffer[_size]; +char MinBatTBuffer[_size]; +char VminBuffer[_size]; +char VmaxBuffer[_size]; +char VavgBuffer[_size]; +char BoardTempBuffer[_size]; + +// Motor +char LMtrTmpBuffer[_size]; +char RMtrTmpBuffer[_size]; +char LAirTmpBuffer[_size]; +char RAirTmpBuffer[_size]; +char LIGBTmpBuffer[_size]; +char RIGBTmpBuffer[_size]; +char Rpm_LBuffer[_size]; +char Rpm_RBuffer[_size]; +char TRequestBufferL[_size]; +char TRequestBufferR[_size]; + +// System Management +char SmallBatCurrentBuffer[_size]; +char ShtdSwtchBuffer[_size]; +char Fan1Buffer[_size]; +char Fan2Buffer[_size]; +char Pump1Buffer[_size]; +char Pump2Buffer[_size]; +char DCDCBuffer[_size]; +char IMDRBuffer[_size]; + +// Miscellaneous Incoming +char CarSpdBuffer[_size]; +char ChargeCurrBuffer[_size]; +char SourceVBuffer[_size]; +char Fault1Buffer[_size]; + +// Outgoing +char ConnectedStatusBuffer = 0; +char DriveStatus; +char DriveStatusRequestBuffer; +char TxResetBuffer = 1; + + +//char CAN1Buffer[_size]; USED IN DEMO +//char CAN2Buffer[_size]; USED IN DEMO +//char CAN3Buffer[_size]; USED IN DEMO +//char CAN4Buffer[_size]; USED IN DEMO \ No newline at end of file
--- a/CANBuffer.lib Sat Nov 22 22:24:53 2014 +0000 +++ b/CANBuffer.lib Thu Jan 29 04:27:19 2015 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/teams/Penn-Electric-Racing/code/CANBuffer/#4baa7251c6c0 +http://developer.mbed.org/teams/Penn-Electric-Racing/code/CANBuffer/#55f8413e1bd6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CAN_Address.h Thu Jan 29 04:27:19 2015 +0000 @@ -0,0 +1,43 @@ +#define TX_BASE 0x300 // TX IDs start at 0x300 +#define TX_DUMP_OFFSET 0x100 // Bulk data dumps start at ID 0x300+0x100 = 0x400 for dumping current RAM and freezeFrames + +//Home Screen Addresses +#define SOC_TX_ID TX_BASE + 0x0B +#define SYS_GLV_SOC_ID 0x513 +#define PCM_FRPM_ID 0x222 +#define TEMP_MMA_TX_ID_BASE TX_BASE + 0x18 +#define TEMP_MMA_TX_ID_BASE2 TX_BASE + 0x19 +#define MOC_MOTEMP_ID 0x212 + +//Battery Screen Addresses +#define VOLTAGE_TX_ID TX_BASE + 0x08 +#define POWER_TX_ID TX_BASE + 0x09 +#define CURRENT_TX_ID TX_BASE + 0x06 +#define CELLV_MMA_TX_ID_BASE TX_BASE + 0x16 +#define CELLV_MMA_TX_ID_BASE2 TX_BASE + 0x17 +#define TEMP_MMA_TX_ID_BASE TX_BASE + 0x18 +#define TEMP_MMA_TX_ID_BASE2 TX_BASE + 0x19 +#define BOARDTEMP_TX_ID TX_BASE + 0x0E + +//Motor Screen Addresses +#define MOC_MOTEMP_ID 0x212 +#define MOC_AIRTEMP_ID 0x213 +#define MOC_IGBTTEMP_ID 0x214 +#define MOC_RPM_ID 0x211 +#define PCM_TORQUERQ_ID 0x231 + +//System Management Addresses +#define SYS_GLV_CURRENT_ID 0x510 +#define SYS_SWITCHES_ID 0x560 +#define SYS_PWM_FAN_ID 0x530 +#define SYS_PWM_PUMP_ID 0x531 +#define SYS_DCDC_STATUS_ID 0x521 +#define SYS_IMD_RESIST_ID 0x541 + +//Charger Addresses +#define CHARGECURR_TX_ID TX_BASE + 0x07 + +//Other Addresses +#define FAULTCODE_TX_ID TX_BASE + 0x00 +#define MODE_TX_ID TX_BASE + 0x01 +#define PCM_PEDALS_ID 0x220 \ No newline at end of file
--- a/KS0108.lib Sat Nov 22 22:24:53 2014 +0000 +++ b/KS0108.lib Thu Jan 29 04:27:19 2015 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/users/tmccurbin/code/KS0108/#4503ff3ebb86 +http://developer.mbed.org/users/tmccurbin/code/KS0108_fork/#7c0770d5639d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Screens.h Thu Jan 29 04:27:19 2015 +0000
@@ -0,0 +1,178 @@
+#include "KS0108.h"
+#include "Buffers.h"
+
+// Macro for printing to screen; Where y is the start poition of the text, and y2 is the start position of the variable
+#define PUT2SCREEN(string, var, unit, x, y, y2) display.PutString(x, y, string); display.PutString(x, y2, var); display.PutString(x,y2+15,unit);
+
+#define HOME_SCREEN 0
+#define BATTERY_SCREEN 1
+#define MOTOR_SCREEN 2
+#define SYS_MGMT_SCREEN 3
+#define CHARGE_SCREEN 4
+#define FAULT_SCREEN 5
+
+
+
+// Initialize Variables
+int CurrScreen = HOME_SCREEN;
+int PrevScreen = !CurrScreen;
+
+// Defines the pins for the dsiplay. These are hardwired.
+KS0108 display(p26, p21, p22, p23, p25, p24, p8, p7, p6, p5, p13, p14, p12, p11);
+
+void DisplayHomeScreen()
+{
+ display.ClearScreen();
+ display.PutString(0, 54, "Home");
+
+ //Info line 1: Battery Life & Vehicle Speed
+ PUT2SCREEN("BatLife:", BigBatLifeBuffer, "%", 1, 0, 39);
+ PUT2SCREEN(",", SmallBatLifeBuffer, "%", 1, 59, 62);
+ PUT2SCREEN("Spd:", CarSpdBuffer, "", 1, 89,108);
+
+ //Info line 2: Average Battery Temp & Peak Battery Temp
+ PUT2SCREEN("AvgBatT:", AvgBatTBuffer, "F", 3, 0, 39);
+ PUT2SCREEN("PkBatT:", MaxBatTBuffer, "F", 3, 69,103);
+
+ //Info line 3: Left Motor Temp & Right Motor Temp
+ PUT2SCREEN("LMtTmp:", LMtrTmpBuffer, "F", 5, 0, 34);
+ PUT2SCREEN("RMtTmp:", RMtrTmpBuffer, "F", 5, 69,103);
+
+ //Fault line
+ display.PutString(7, 14, "Reserved for faults");
+}
+
+void DisplayBatteryScreen()
+{
+ display.ClearScreen();
+ display.PutString(0, 34, "Main Battery");
+
+ //Info line 1: Battery Voltage, Power & Current
+ PUT2SCREEN("V:", BigBatVoltBuffer, "V", 1, 0, 10);
+ PUT2SCREEN("P:", BigBatPowerBuffer, "W", 1, 45, 55);
+ PUT2SCREEN("I:", BigBatCurrentBuffer, "A", 1, 90,100);
+
+ //Info line 2: High, Low, & Average Cell Voltage
+ PUT2SCREEN("Vmx:", VmaxBuffer, "V", 3, 0, 20);
+ PUT2SCREEN("Vmn:", VminBuffer, "", 3, 47, 67);
+ PUT2SCREEN("Vav:", VavgBuffer, "", 3, 88,108);
+
+ //Info line 3: High, Low, & Average Cell Temp
+ PUT2SCREEN("Tmx:", MaxBatTBuffer, "F", 5, 0, 20);
+ PUT2SCREEN("Tmn:", MinBatTBuffer, "", 5, 47, 67);
+ PUT2SCREEN("Tav:", AvgBatTBuffer, "", 5, 88,108);
+
+ //Info line 4: Highest Board Temp
+ PUT2SCREEN("HighBoardTemp:", BoardTempBuffer, "F", 7, 17, 87);
+}
+
+void DisplayMotorScreen()
+{
+ display.ClearScreen();
+ display.PutString(0, 52, "Motor");
+
+ //Info line 1: Left Motor Temp & Right Motor Temp
+ PUT2SCREEN("LMtTmp:", LMtrTmpBuffer, "F", 1, 0, 34);
+ PUT2SCREEN("RMtTmp:", RMtrTmpBuffer, "F", 1, 64, 98);
+
+ //Info line 2: Left & Right Air Temp
+ PUT2SCREEN("LAirTp:", LAirTmpBuffer, "F", 2, 0, 34);
+ PUT2SCREEN("RairTp:", RAirTmpBuffer, "F", 2, 64, 98);
+
+ //Info line 3: Left & Right IGBT Temp
+ PUT2SCREEN("LIGBTp:", LIGBTmpBuffer, "F", 3, 0, 34);
+ PUT2SCREEN("RIGBTp:", RIGBTmpBuffer, "F", 3, 64, 98);
+
+ //Info line 4: Left & Right Motor RPM
+ PUT2SCREEN("Rpm-L:", Rpm_LBuffer, "", 5, 0, 30);
+ PUT2SCREEN("Rpm-R:", Rpm_RBuffer, "", 5, 77,107);
+
+ //Info line 5: Torque Request (Throttle)
+ PUT2SCREEN("Torque Request:", TRequestBufferL, "%", 7, 0, 75);
+ PUT2SCREEN(",", TRequestBufferR, "%", 7, 95, 98);
+}
+
+void DisplaySysMgmtScreen()
+{
+ display.ClearScreen();
+ display.PutString(0, 22, "System Management");
+
+ //Info line 1: Small Battery Current & Shutdown Switch State
+ PUT2SCREEN("I_GLV:", SmallBatCurrentBuffer,"A", 1, 0, 30);
+ PUT2SCREEN("ShtdSwtch:", ShtdSwtchBuffer, "", 1, 58,108);
+
+ //Info line 2: Fan Duty Cycle
+ PUT2SCREEN("Fan-1:", Fan1Buffer, "", 3, 0, 30);
+ PUT2SCREEN("Fan-2:", Fan2Buffer, "", 3, 77,107);
+
+ //Info line 3: Pump Duty Cycle
+ PUT2SCREEN("Pump1:", Pump1Buffer, "", 5, 0, 30);
+ PUT2SCREEN("Pump2:", Pump2Buffer, "", 5, 77,107);
+
+ //Info line 4: DCDC & IMD Status
+ PUT2SCREEN("DCDC :", DCDCBuffer, "", 7, 0, 30);
+ PUT2SCREEN(" IMD :", IMDRBuffer, "", 7, 77,107);
+}
+
+void DisplayFaultScreen()
+{
+ display.ClearScreen();
+ display.PutString(0, 49, "Faults");
+
+ //Info line 1: Battery Voltage, Power & Current
+ PUT2SCREEN("", Fault1Buffer, "", 1, 0, 0);
+ PUT2SCREEN("", Fault1Buffer, "", 2, 0, 0);
+ PUT2SCREEN("", Fault1Buffer, "", 3, 0, 0);
+ PUT2SCREEN("", Fault1Buffer, "", 4, 0, 0);
+ PUT2SCREEN("", Fault1Buffer, "", 5, 0, 0);
+ PUT2SCREEN("", Fault1Buffer, "", 6, 0, 0);
+ PUT2SCREEN("", Fault1Buffer, "", 7, 0, 0);
+}
+
+void DisplayChargeScreen()
+{
+ display.ClearScreen();
+ display.PutString(0, 44, "CHARGING");
+
+ // Battery Voltage, Charge Current, & Source Voltage
+ PUT2SCREEN("Battery Voltage :", BigBatVoltBuffer, "V", 1, 9, 94);
+ PUT2SCREEN("Charging Current:", ChargeCurrBuffer, "V", 3, 9, 94);
+ PUT2SCREEN("Source Voltage :", SourceVBuffer, "F", 5, 12, 92);
+}
+
+void ToggleScreen()
+{
+ CurrScreen = (CurrScreen+1) %5;
+}
+
+void DisplayCurrScreen(void const *args)
+{
+ while(1) {
+ if(PrevScreen != CurrScreen) {
+ switch(CurrScreen) {
+ case 0:
+ DisplayHomeScreen();
+ break;
+ case 1:
+ DisplayBatteryScreen();
+ break;
+ case 2:
+ DisplayMotorScreen();
+ break;
+ case 3:
+ DisplaySysMgmtScreen();
+ break;
+ case 4:
+ DisplayChargeScreen();
+ break;
+ case 5:
+ DisplayFaultScreen();
+ break;
+ default:
+ break;
+ }
+ PrevScreen = CurrScreen;
+ }
+ }
+
+}
\ No newline at end of file
--- a/Steering.cpp Sat Nov 22 22:24:53 2014 +0000
+++ b/Steering.cpp Thu Jan 29 04:27:19 2015 +0000
@@ -1,187 +1,297 @@
#include "Steering.h"
-bool NOT_biSWBL_HELD;
-bool NOT_biSWTR_HELD;
+// To-Do:
+// Look at SYS management CAN translations: shutdown switches, DCDC status, & IMD status
+// Figure out screen/variable updating options
+// Firgure out fault protocall
+
+void Init();
+void ProcessButtons(void const *args);
+void RequestStatusChange();
+void ResetSteeringWheel();
+void ResetCar();
+void ProcessCANMsg(CANMessage& msg);
+void UpdateDisplay();
+void ProcessButtons(void const *args);
+void ConnectedStatusCANMsg();
+
+float CANFloat;
+float CANFloat2;
+
+Ticker StatusMsg;
-void update_display(void const *args){
-
- while(true){
-
- if(screen_flags[curr_screen] || should_redraw){
- screen_flags[curr_screen] = 0;
- should_redraw = false;
- switch(curr_screen){
-
- case HOME_SCREEN:{
-
- display.ClearScreen();
- display.SelectFont(Arial10,BLACK,ReadData);
- display.GotoXY(37,0);
- display.PrintString(" Home Screen");
-
- display.GotoXY(22,30);
- if(vars_list->get_value(PCM_STATE_ID) == 0){
- display.PutString(17, 30, "Drive Status: OFF");
- }
- else{
- display.PrintString("Drive Status: ON");
- }
- break;
- }
-
- case BATTERY_SCREEN:
-
- display.ClearScreen();
- display.SelectFont(Arial10,BLACK,ReadData);
- display.GotoXY(33,0);
- display.PrintString(" Battery Screen");
- break;
-
- default:
- break;
-
- }
+int main()
+{
+ Init();
+
+ display.GotoXY(10,16);
+ display.SelectFont(Arial_14,BLACK,ReadData);
+ display.PrintString("Penn Electric Racing");
+ wait(2);
+ display.ClearScreen();
+ display.GotoXY(10,16);
+ display.PrintString("Live the dream.");
+ wait(2);
+
+ Thread Thread2(ProcessButtons);
+ Thread Thread1(DisplayCurrScreen);
+
+ while(1) {
+ CANMessage Rxmsg;
+ if (SteeringCANPort.rxRead(Rxmsg)) {
+ ProcessCANMsg(Rxmsg);
}
- wait(2);
}
}
-void toggle_screen(){
- should_redraw = true;
- curr_screen = (curr_screen+1) % NUM_SCREEN;
-}
-
-void request_status_change(){
-
- char drive_status_request;
- ds_mutex.lock();
- drive_status_request = !(vars_list->get_value(PCM_STATE_ID));
-
- ds_mutex.unlock();
- char * status_string;
-
- if(drive_status_request){
- status_string = "ON";
- }
- else{
- status_string = "OFF";
- }
-
- CANMessage Txmsg_drive_status_request(0x501,&drive_status_request,1);
- for(int i = 0; i < 10; i++){
- CAN_Steering_Buffer.txWrite(Txmsg_drive_status_request);
- }
-
- printf("%s\n\r", status_string);
- return;
-}
-
-void reset()
-{
- reset_body = 1;
- CANMessage Txmsg_reset(0x502,&reset_body,1);
- for(int i = 0; i < 10; i++){
- CAN_Steering_Buffer.txWriteDirect(Txmsg_reset);
- }
- NVIC_SystemReset();
- display.ClearScreen();
- display.SelectFont(Arial12,BLACK,ReadData);
- display.GotoXY(16,16);
- printf("Reset Initiated\n\r");
-
- return;
-}
void Init()
{
- should_redraw = true;
+ StatusMsg.attach(&ConnectedStatusCANMsg,0.1);
pc.baud(921600);
- curr_screen = HOME_SCREEN;
- drive_status = 0;
- drive_status_request = 1;
- reset_body = 0;
- ledstream.write(0);
- NOT_biSWBL_HELD = true;
- NOT_biSWTR_HELD = true;
-
- vars_list = new variables();
-
- vars_list->add(PCM_STATE_ID, HOME_SCREEN);
- vars_list->add(BATTERY_VOLTAGE_ID, BATTERY_SCREEN);
- vars_list->add(BATTERY_POWER_ID, BATTERY_SCREEN);
- vars_list->add(BATTERY_CURRENT_ID, BATTERY_SCREEN);
-
+ BLButtonRed;
+ BRButtonGreen;
+ TLButtonGreen;
+ TRButtonGreen;
+ DriveStatus = 0; // Off
+ //initialize screen Startup Process
+ wait(2);
}
-void read_messages(void const *args) {
-
- while (true) {
-
- CANMessage Rxmsg;
- if(CAN_Steering_Buffer.rxRead(Rxmsg)){
- id_node = vars_list->get_node(Rxmsg.id);
- if(id_node != NULL){
- if(id_node->value != Rxmsg.data[0]){
- screen_flags[id_node->screen] = 1;
- }
- id_node->value = Rxmsg.data[0];
+
+void ProcessButtons(void const *args)
+{
+ while(1) {
+ Thread::wait(50);
+ if(biSWBR.read()) {
+ Thread::wait(750);
+ if (biSWBR.read()) {
+ ResetCar();
+ }
+ NVIC_SystemReset();
+ ResetSteeringWheel();
+ }
+
+ if(biSWBL.read()) {
+ Thread::wait(1000);
+ if (biSWBL.read()) {
+ RequestStatusChange();
}
}
+
+ if(biSWTR.read() && CurrScreen != 5) {
+ //If the toggle button is pressed and the screen isn't on Fault_Screen
+ ToggleScreen();
+ Thread::wait(250);
+ } else if (biSWTR.read() && CurrScreen == 5) {// If the screen was on Fault, go to Home
+ CurrScreen = 0;
+ Thread::wait(250);
+ }
+
+ if(biSWTL.read() && CurrScreen != 0) {
+ //If the Home button is pressed and the screen isn't on Fault_Screen
+ CurrScreen = 0;
+ Thread::wait(250);
+ } else if (biSWTL.read() && CurrScreen == 0) {// If the screen was on Fault, go to Home
+ CurrScreen = 5;
+ Thread::wait(250);
+ }
}
}
-int main(){
- // Initialize, set all variables.
- Init();
- wait(0.1);
-
- //Init Display
- display.GotoXY(10,16);
- display.SelectFont(Arial_14,BLACK,ReadData);
- display.PrintString("Penn Electric Racing");
- CAN_Steering_Buffer.mode(NoAck);
-
- wait(2);
-
- //New thread to read messages.
- Thread update_thread(read_messages);
-
- // display the screen.
- Thread display_thread(update_display);
-
+
+void UpdateDisplay()
+{
+}
+
+
+void ProcessCANMsg(CANMessage& Rxmsg)
+{
+ if (SteeringCANPort.rxRead(Rxmsg)) {
+ printf("Message ID: 0x%x len: %d hex: 0x%x float: %f\r\n", Rxmsg.id, Rxmsg.len, *((int*)((void*)(&Rxmsg.data[0]))), *((float*)((void*)(&Rxmsg.data[0]))));
+ for (int i=0; i < Rxmsg.len; i++) printf("D[%d]: %x ", i, Rxmsg.data[i]);
+ switch (Rxmsg.id) {
- // Start to read buttons on main thread
- while(1)
- {
- if(biSWBL.read() && NOT_biSWBL_HELD){
- request_status_change();
- NOT_biSWBL_HELD = false;
+ // HOME SCREEN *******************************************************************************************
+ case SOC_TX_ID:
+ CANFloat = GetFloat;
+ sprintf(BigBatLifeBuffer,"%3.2d", int(CANFloat*100)); // Big battery life percentage
+ display.PutString(1,40,BigBatLifeBuffer);
+ break;
+ case SYS_GLV_SOC_ID:
+ CANFloat = GetFloat;
+ sprintf(SmallBatLifeBuffer,"%3.2d", int(CANFloat*100)); // Small battery life percentage
+ display.PutString(1,60,SmallBatLifeBuffer);
+ break;
+ case PCM_FRPM_ID:
+ CANFloat = GetFloat;
+ CANFloat2 = GetFloat4;
+ sprintf(CarSpdBuffer,"%3.2d", int((CANFloat+CANFloat2)*WheelCircumference*30)); // Miles per hour
+ display.PutString(1,108,CarSpdBuffer);
+ case TEMP_MMA_TX_ID_BASE2:
+ CANFloat = GetFloat;
+ sprintf(AvgBatTBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32)); // Degrees F
+ display.PutString(3,39,AvgBatTBuffer);
+ //display.PutString(5,108,AvgBatTBuffer); this is for the battery screen
+ case TEMP_MMA_TX_ID_BASE:
+ CANFloat2 = GetFloat4;
+ sprintf(MaxBatTBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32)); // Figure out Max/Min and Figure out various screen display
+ display.PutString(3,103,MaxBatTBuffer);
+ //display.PutString(5,20,MaxBatTBuffer); this is for the battery screen
+ CANFloat = GetFloat;
+ sprintf(MinBatTBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32));
+ //display.PutString(5,67,MinBatTBuffer); this is for the battery screen
+ case MOC_MOTEMP_ID:
+ CANFloat = GetFloat;
+ sprintf(LMtrTmpBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32)); // We need to figure out how to handle the bytes for left and right motors
+ display.PutString(5,34,LMtrTmpBuffer);
+ // display.PutString(1,34,LMtrTmpBuffer); this is for the motor screen
+ CANFloat2 = GetFloat4;
+ sprintf(RMtrTmpBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32)); // We need to figure out how to handle the bytes for left and right motors
+ display.PutString(5,34,RMtrTmpBuffer);
+ //display.PutString(1,98,LMtrTmpBuffer); this is for the motor screen
+ // BATTERY SCREEN***********************************************************************************
+ case VOLTAGE_TX_ID:
+ CANFloat = GetFloat;
+ sprintf(BigBatVoltBuffer,"%3.2d", int(CANFloat)); // Volts
+ //display.PutString(1,10,BigBatVoltBuffer);
+ //display.PutString(3,94,BigBatVoltBuffer); this is for the charging screen
+ case POWER_TX_ID:
+ CANFloat = GetFloat;
+ sprintf(BigBatPowerBuffer,"%3.2d", int(CANFloat)); // Watts
+ //display.PutString(1,55,BigBatPowerBuffer);
+ case CURRENT_TX_ID:
+ CANFloat = GetFloat;
+ sprintf(BigBatCurrentBuffer,"%3.2d", int(CANFloat)); // Amps
+ //display.PutString(1,100,BigBatCurrentBuffer);
+ case CELLV_MMA_TX_ID_BASE:
+ CANFloat2 = GetFloat4;
+ sprintf(VmaxBuffer,"%3.2d", int(CANFloat2)); // We need to figure out how to handle max and min
+ //display.PutString(3,20,VmaxBuffer);
+ CANFloat = GetFloat;
+ sprintf(VminBuffer,"%3.2d", int(CANFloat));
+ //display.PutString(3,67,VminBuffer);
+ case CELLV_MMA_TX_ID_BASE2:
+ CANFloat = GetFloat;
+ sprintf(VavgBuffer,"%3.2d", int(CANFloat)); // Volts
+ //display.PutString(3,108,VavgBuffer);
+ case BOARDTEMP_TX_ID:
+ CANFloat = GetFloat;
+ sprintf(BoardTempBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32)); // Degrees F
+ //display.PutString(7,87,BoardTempBuffer);
+
+ // MOTOR SCREEN*****************************************************************
+ case MOC_AIRTEMP_ID:
+ CANFloat = GetFloat;
+ sprintf(LAirTmpBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32)); // Figure out the left and the right
+ //display.PutString(2,34,LAirTmpBuffer);
+ CANFloat2 = GetFloat4;
+ sprintf(RAirTmpBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32)); // Degrees F
+ //display.PutString(2,98,RAirTmpBuffer);
+ case MOC_IGBTTEMP_ID:
+ CANFloat = GetFloat;
+ sprintf(LIGBTmpBuffer,"%3.2d", int((CANFloat*9.0/5.0)+32)); // Figure out the left and the right
+ //display.PutString(3,34,LIGBTmpBuffer);
+ CANFloat2 = GetFloat4;
+ sprintf(RIGBTmpBuffer,"%3.2d", int((CANFloat2*9.0/5.0)+32)); // Degrees F
+ //display.PutString(3,98,RIGBTmpBuffer);
+ case MOC_RPM_ID:
+ CANFloat = GetFloat;
+ sprintf(Rpm_LBuffer,"%3.2d", int(CANFloat)); // Figure out the left and the right
+ //display.PutString(5,30,Rpm_LBuffer);
+ CANFloat2 = GetFloat4;
+ sprintf(Rpm_RBuffer,"%3.2d", int(CANFloat2));
+ //display.PutString(5,107,Rpm_RBuffer);
+ case PCM_TORQUERQ_ID:
+ CANFloat = GetFloat;
+ sprintf(TRequestBufferL,"%3.2d", int(CANFloat*100)); // Percentage
+ //display.PutString(7,89,TRequestBufferL);
+ CANFloat2 = GetFloat4;
+ sprintf(TRequestBufferR,"%3.2d", int(CANFloat2*100)); // Percentage
+ //display.PutString(7,89,TRequestBufferR);
+
+ // SYSTEM MANAGEMENT SCREEN***************************************************
+ case SYS_GLV_CURRENT_ID:
+ CANFloat = GetFloat;
+ sprintf(SmallBatCurrentBuffer,"%3.2d", int(CANFloat)); // Amps
+ //display.PutString(1,30,SmallBatCurrentBuffer);
+ case SYS_SWITCHES_ID:
+ CANFloat = GetFloat;
+ sprintf(ShtdSwtchBuffer,"%3.2d", int(CANFloat)); // How the heck are we interpreting this data
+ //display.PutString(1,108,ShtdSwtchBuffer);
+ case SYS_PWM_FAN_ID:
+ CANFloat = GetFloat;
+ sprintf(Fan1Buffer,"%3.2d", int(CANFloat*100)); // Duty Cycle. Figure out the left and the right
+ //display.PutString(3,30,Fan1Buffer);
+ CANFloat2 = GetFloat4;
+ sprintf(Fan2Buffer,"%3.2d", int(CANFloat2*100));
+ //display.PutString(3,107,Fan2Buffer);
+ case SYS_PWM_PUMP_ID:
+ CANFloat = GetFloat;
+ sprintf(Pump1Buffer,"%3.2d", int(CANFloat*100)); // Duty Cycle. Figure out the left and the right
+ //display.PutString(5,30,Pump1Buffer);
+ CANFloat2 = GetFloat4;
+ sprintf(Pump2Buffer,"%3.2d", int(CANFloat2*100));
+ //display.PutString(5,107,Pump2Buffer);
+ case SYS_DCDC_STATUS_ID:
+ CANFloat = GetFloat;
+ sprintf(DCDCBuffer,"%3.2d", int(CANFloat)); // How the heck are we interpreting this data
+ //display.PutString(7,30,DCDCBuffer);
+ case SYS_IMD_RESIST_ID:
+ CANFloat = GetFloat;
+ sprintf(IMDRBuffer,"%3.2d", int(CANFloat)); // How the heck are we interpreting this data
+ //display.PutString(7,107,IMDRBuffer);
+
+ // CHARGER SCREEN *************************************************************
+ case CHARGECURR_TX_ID:
+ CANFloat = GetFloat;
+ sprintf(ChargeCurrBuffer,"%3.2d", int(CANFloat)); // Amps
+ //display.PutString(3,94,ChargeCurrBuffer);
+ // OTHER **********************************************************************
+ case MODE_TX_ID:
+ CANFloat = GetFloat;
+ sprintf(&DriveStatus,"%3.2d", int(CANFloat)); //confirm that I am interpreting this correctly
+ if (DriveStatus == 1) {
+ BLButtonGreen;
+ } else {
+ BLButtonRed;
+ }
+ default:
+ break;
}
-
- else if(!biSWBL.read()){
- NOT_biSWBL_HELD = true;
- }
-
- else{
- // ignore BiSWBL.read()
- }
-
- if(biSWTR.read() && NOT_biSWTR_HELD){
- toggle_screen();
- NOT_biSWTR_HELD = false;
- }
-
- else if(!biSWTR.read()){
- NOT_biSWTR_HELD = true;
- }
-
- else{
- // ignore BiSWTR.read()
- }
-
- if(biSWBR.read()){
- reset();
- }
- }
-}
+ }
+}
+
+void ConnectedStatusCANMsg()
+{
+ CANMessage ConnectedStatus(0x600, &ConnectedStatusBuffer,1);
+ SteeringCANPort.txWrite(ConnectedStatus);
+}
+
+void RequestStatusChange()
+{
+ DriveStatusRequestBuffer = !DriveStatus;
+ CANMessage TxDriveStatusRequest(0x601, &DriveStatusRequestBuffer,1);
+ for (int j=0; j<10; j++) {
+ SteeringCANPort.txWrite(TxDriveStatusRequest);
+ }
+ display.PutString(7,0," DRIVE REQUEST SENT ");
+ Thread::wait(750);
+ PrevScreen = !CurrScreen; // To force a screen update
+}
+
+
+void ResetSteeringWheel()
+{
+ NVIC_SystemReset();
+}
+
+
+void ResetCar()
+{
+ CANMessage TxCarReset(0x602,&TxResetBuffer,1);
+ for (int k=0; k<10; k++) {
+ SteeringCANPort.txWriteDirect(TxCarReset);
+ }
+}
\ No newline at end of file
--- a/Steering.h Sat Nov 22 22:24:53 2014 +0000
+++ b/Steering.h Thu Jan 29 04:27:19 2015 +0000
@@ -2,154 +2,49 @@
#define _STEERING_H
#include "mbed.h"
+#include <math.h>
#include "rtos.h"
#include "KS0108.h"
-
-#include "Arial10.h"
-#include "Arial12.h"
#include "Arial14.h"
-#include "Comic24.h"
-#include "vivaldi16.h"
#include "CANBuffer.h"
-#include "variables.h"
-
+#include "CAN_Address.h"
+#include "Screens.h"
-#include "LPCDigitalIn.h"
+#define GetFloat *(float*)((void*)(&Rxmsg.data[0]))
+#define GetFloat4 *(float*)((void*)(&Rxmsg.data[4]))
-#define SWITCH_ID 410
+#define BLButtonGreen DigitalOut l3(P1_24,1); DigitalOut l4(P0_24,0); // SW6, SW8 respectively
+#define BLButtonRed DigitalOut l3(P1_24,0); DigitalOut l4(P0_24,1);
-#define BATTERY_VOLTAGE_ID 0x304
-#define BATTERY_POWER_ID 0x306
-#define BATTERY_CURRENT_ID 0x305
+#define BRButtonGreen DigitalOut l1(P1_28,1); DigitalOut l2(P1_26,0); // SW2, SW4 respectively
+#define BRButtonRed DigitalOut l1(P1_28,0); DigitalOut l2(P1_26,1);
-#define PCM_STATE_ID 0x201
-
-#define BATTERY_MIN_CELLVOLTAGE_ID 0x301
-#define BATTERY_MAX_CELLVOLTAGE_ID 0x300
-#define BATTERY_AVG_CELLVOLTAGE_ID 0x302
+#define TLButtonGreen DigitalOut u3(P1_4,0); DigitalOut u4(P1_0,1); // SW13, SW15 respectively
+#define TLButtonRed DigitalOut u3(P1_4,1); DigitalOut u4(P1_0,0);
-#define BATTERY_MIN_CELLTEMPERATURE_ID 0x30A
-#define BATTERY_MAX_CELLTEMPERATURE_ID 0x309
-#define BATTERY_AVG_CELLTEMPERATURE_ID 0x30B
-#define AMS_BATTERY_STATE 0x30E // AIRS 7 and 6 // Precharge 3
+#define TRButtonGreen DigitalOut u1(P1_14,0); DigitalOut u2(P1_9,1); // SW9, SW11 respectively
+#define TRButtonRed DigitalOut u1(P1_14,1); DigitalOut u2(P1_9,0);
-#define NUM_SCREEN 2
-
-#define HOME_SCREEN 0
-#define BATTERY_SCREEN 1
+float pi = 3.14159;
+float WheelRadius = 5/6; // In feet; same as 10 inches
+float WheelCircumference = 2*pi*WheelRadius; //In feet
Serial pc(USBTX,USBRX);
-CANBuffer CAN_Steering_Buffer(CAN1, MEDIUM, p3_26);
-
-KS0108 display(p26, p21, p22, p23, p25, p24, p8, p7, p6, p5, p13, p14, p12, p11);
-//Ticker call_ledstream;
-
-LPCDigitalOut l1(p1_28,1);// SW2
-LPCDigitalOut l2(p1_26,1);// SW4
-
-LPCDigitalOut l3(p1_24,1);// SW6
-LPCDigitalOut l4(p0_24,1);// SW8
-
-LPCDigitalOut u1(p1_14,0);// SW9
-LPCDigitalOut u2(p1_9,0);// SW11
-
-LPCDigitalOut u3(p1_4,0);// SW13
-LPCDigitalOut u4(p1_0,0);// SW15
-
-AnalogOut ledstream(p18);
-
-//SW1 - SW3
-LPCDigitalOut boSW1(p1_29,1);
-LPCDigitalIn biSWBR(p1_27, PullDown); //BRight
+CANBuffer SteeringCANPort(CAN1, MEDIUM, P3_26); // Initialize the CAN port/pin
-LPCDigitalOut boSW5(p1_25,1);
-LPCDigitalIn biSWBL(p1_22, PullDown); //BLeft
-
-LPCDigitalOut boSW10(p1_10,1);
-LPCDigitalIn biSWTR(p1_8, PullDown); //TRight
-
-LPCDigitalOut boSW14(p1_1,1);
-LPCDigitalIn biSWTL(p0_25, PullDown); //TLeft
-
-typedef union convert{
- float FLOAT;
- char C_FLOAT[4];
- }ftc;
+AnalogOut ledstream(p18); // This appears to iniialize the pin as an analog out, and probably defaults to low. Without this, the LED bar would have a few lights on.
-char SwitchName[15][13]={
- "fuse",
- "ams",
- "imd",
- "pcm",
- "brkp",
- "lft",
- "intl",
- "brko",
- "ckpt",
- "rgt",
- "hvd",
- "tsms"
-};
+DigitalOut boSW1(P1_29,1);// SW1
+DigitalIn biSWBR(P1_27, PullDown);// SW3, BRight
-int SwitchPosition[13][2]={
- {0,16}, //fuse
- {25,16}, //ams
- {50,16}, //imd
- {70,16}, //pcm
- {93,16}, //brkp
- {117,16}, //lft
- {0,32}, //intl
- {17,32}, //brko
- {42,32}, //ckpt
- {65,32}, //rgt
- {81,32}, //hvd
- {102,32}, //tsm
- };
-
-int curr_screen;
-int screen_flags[NUM_SCREEN];
-bool should_redraw;
-
-char drive_status;
-char drive_status_request;
-char reset_body;
-
-node * id_node = NULL;
-variables * vars_list;
-
-
-Mutex ds_mutex;
+DigitalOut boSW5(P1_25,1);// SW5
+DigitalIn biSWBL(P1_22, PullDown);// SW7, BLeft
-/*
-void read_messages(void const *args) {
-
- while (true) {
- CANMessage Rxmsg;
-
- if(CAN_Steering_Buffer.rxRead(Rxmsg))
- if(Rxmsg.id == PCM_STATE_ID){
-
- // Mutex to protex shared variables
- ds_mutex.lock();
- drive_status = Rxmsg.data[0];
- ds_mutex.unlock();
- }
-
- if(Rxmsg.id == BATTERY_POWER_ID)
- {
- float power_ratio;
- ftc rcv;
- rcv.FLOAT=0.0;
-
- for(int i=0; i<4; i++){
- rcv.C_FLOAT[i] = Rxmsg.data[i];
- }
- power_ratio=rcv.FLOAT/80000;
- ledstream.write(power_ratio);
- }
- }
- }
-*/
+DigitalOut boSW10(P1_10,1);// SW10
+DigitalIn biSWTR(P1_8, PullDown);// SW12, TRight
-#endif /* STEERING_H */
\ No newline at end of file
+DigitalOut boSW14(P1_1,1);// SW14
+DigitalIn biSWTL(P0_25, PullDown);// SW16, TLeft
+
+#endif //_STEERING_H
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/demo.h Thu Jan 29 04:27:19 2015 +0000
@@ -0,0 +1,81 @@
+// FORMAT_CODE_START
+// FORMAT_CODE_START
+#include "Steering.h"
+
+// Macro for printing to screen; Where y is the start poition of the text, and y2 is the start position of the variable
+#define PUT2SCREEN(string, var, unit, x, y, y2) display.PutString(x, y, string); display.PutString(x, y2, var); display.PutString(x,y2+15,unit);
+
+unsigned int x = 0;
+unsigned int x_old = 0;
+unsigned int x_new;
+int diff = x_new-x_old;
+int threshold = 1;
+float y = 0.0;
+
+void update_x(void const *args)
+{
+ while (1) {
+ x++;
+ wait_ms(1); //I added this because the microcontroller was operating so fast that you couldn't read the numbers.
+ if (x >= 16000) {
+ x = 0;
+ }
+
+ x_new = x;
+ diff = x_new - x_old;
+ }
+}
+
+void update_y(void const *args)
+{
+ while(1) {
+ y = y + 0.000001;
+ if (y >= 1.0) {
+ y = 0;
+
+ }
+ }
+
+}
+
+AnalogOut ledBar(p18);
+
+
+int main()
+{
+ wait(1);
+
+ Thread thread(update_x);
+
+ Thread thread2(update_y);
+
+
+ display.PutString(0, 42, "Live Test");
+
+ PUT2SCREEN("CAN-1:", CAN1Buffer, "", 3, 0, 30);
+ PUT2SCREEN("CAN-2:", CAN2Buffer, "", 3, 77,107);
+
+
+
+ PUT2SCREEN("CAN-3:", CAN3Buffer, "", 5, 0, 30);
+ PUT2SCREEN("CAN-4:", CAN4Buffer, "", 5, 77,107);
+
+ while (1) {
+ printf("x = %d y = %f\n", x, y); //9600 baud (default)
+
+ ledBar = y*(2.7/3.3);
+
+ if (abs(diff) >= threshold) {
+ display.GotoXY(30,24);
+ //display.PutString(3,30, " ");
+ display.PrintInteger(x,3,30);
+ display.PrintInteger(x,3,107);
+ display.PrintInteger(x,5,30);
+ display.PrintInteger(x,5,107);
+ x_old = x_new;
+ }
+ }
+
+}
+// FORMAT_CODE_END
+// FORMAT_CODE_END
\ No newline at end of file
--- a/mbed-rtos.lib Sat Nov 22 22:24:53 2014 +0000 +++ b/mbed-rtos.lib Thu Jan 29 04:27:19 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed-rtos/#631c0f1008c3 +http://developer.mbed.org/users/mbed_official/code/mbed-rtos/#444020d511f5
--- a/mbed.bld Sat Nov 22 22:24:53 2014 +0000 +++ b/mbed.bld Thu Jan 29 04:27:19 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/031413cf7a89 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5 \ No newline at end of file
--- a/node.h Sat Nov 22 22:24:53 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-class node{
-
- public:
-
- node();
- node(int id, int screen);
- void set_val(char v);
- ~node();
-
- int screen;
- int id;
- char value;
- node * next;
-
-};
-
-node::node(){
- screen = 0;
- id = 0;
- next = NULL;
-}
-
-node::node(int i, int s){
- id = i;
- screen = s;
- next = NULL;
-}
-
-void node::set_val(char v){
- value = v;
-}
-
-node::~node(){
-}
-
\ No newline at end of file
--- a/variables.h Sat Nov 22 22:24:53 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,117 +0,0 @@
-#include "node.h"
-
-class variables{
-
- public:
-
- variables();
- ~variables();
- void add(int i, int s);
- int get_screen(int i);
- char get_value(int i);
- int set_value(int i, char v);
- node * get_node(int i);
-
-
- int size;
- node * head;
- node * tail;
-
-};
-
-variables::variables(){
- size = 0;
- head = NULL;
- tail = NULL;
-}
-
-variables::~variables(){
-
- node * curr = head;
- node * next = head;
-
- while(curr != NULL){
- next = curr->next;
- delete(curr);
- curr = next;
- }
-
- head = NULL;
- tail = NULL;
- size = 0;
-}
-
-void variables::add(int i, int s){
-
- if(head == NULL){
- head = new node(i, s);
- tail = head;
- }
-
- else{
- tail->next = new node(i,s);
- tail = tail->next;
- }
- size++;
-}
-
-node * variables::get_node(int i){
-
- node * curr = head;
-
- while(curr != NULL){
- if(curr->id == i){
- return curr;
- }
- else{
- curr = curr->next;
- }
- }
- return NULL;
-}
-
-int variables::get_screen(int i){
-
- node * curr = head;
-
- while(curr != NULL){
- if(curr->id == i){
- return curr->screen;
- }
- else{
- curr = curr->next;
- }
- }
- return -1;
-}
-
-int variables::set_value(int i, char v){
-
- node * curr = head;
-
- while(curr != NULL){
- if(curr->id == i){
- curr->set_val(v);
- return 0;
- }
- else{
- curr = curr->next;
- }
- }
- return -1;
-}
-
-char variables::get_value(int i){
-
- node * curr = head;
-
- while(curr != NULL){
- if(curr->id == i){
- return curr->value;
- }
- else{
- curr = curr->next;
- }
- }
- return 0;
-}
\ No newline at end of file
