The Code Repository for the REV0 Steering Wheel.

Dependencies:   CANBuffer KS0108_fork mbed-rtos mbed CAN Addresses

Fork of REVO_Updated_Steering by Penn Electric

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers demo.h Source File

demo.h

00001 /*
00002 // FORMAT_CODE_START
00003 // FORMAT_CODE_START
00004 #include "Steering.h"
00005 
00006 // Macro for printing to screen; Where y is the start poition of the text, and y2 is the start position of the variable
00007 #define PUT2SCREEN(string, var, unit, x, y, y2)   display.PutString(x, y,  string);   display.PutString(x, y2, var);   display.PutString(x,y2+15,unit);
00008 
00009 unsigned int x = 0;
00010 unsigned int x_old = 0;
00011 unsigned int x_new;
00012 int diff = x_new-x_old;
00013 int threshold = 1;
00014 float y = 0.0;
00015 
00016 void update_x(void const *args)
00017 {
00018     while (1) {
00019         x++;
00020         wait_ms(1);         //I added this because the microcontroller was operating so fast that you couldn't read the numbers.
00021         if (x >= 16000) {
00022             x = 0;
00023         }
00024 
00025         x_new = x;
00026         diff = x_new - x_old;
00027     }
00028 }
00029 
00030 void update_y(void const *args)
00031 {
00032     while(1) {
00033         y = y + 0.000001;
00034         if (y >= 1.0) {
00035             y = 0;
00036 
00037         }
00038     }
00039 
00040 }
00041 
00042 AnalogOut ledBar(p18);
00043 
00044 
00045 int main()
00046 {
00047     wait(1);
00048 
00049     Thread thread(update_x);
00050 
00051     Thread thread2(update_y);
00052 
00053 
00054     display.PutString(0, 42, "Live Test");
00055 
00056     PUT2SCREEN("CAN-1:",      CAN1Buffer,      "",     3,  0, 30);
00057     PUT2SCREEN("CAN-2:",      CAN2Buffer,      "",     3, 77,107);
00058 
00059 
00060 
00061     PUT2SCREEN("CAN-3:",      CAN3Buffer,      "",     5,  0, 30);
00062     PUT2SCREEN("CAN-4:",      CAN4Buffer,      "",     5, 77,107);
00063 
00064     while (1) {
00065         printf("x = %d y = %f\n", x, y);  //9600 baud (default)
00066 
00067         ledBar = y*(2.7/3.3);
00068         
00069         if (abs(diff) >= threshold) {
00070             display.GotoXY(30,24);
00071             //display.PutString(3,30, "   ");
00072             display.PrintInteger(x,3,30);
00073             display.PrintInteger(x,3,107);
00074             display.PrintInteger(x,5,30);
00075             display.PrintInteger(x,5,107);
00076             x_old = x_new;
00077         }
00078     }
00079 
00080 }
00081 // FORMAT_CODE_END
00082 // FORMAT_CODE_END
00083 */