Xavier Gouesnard / Mbed 2 deprecated Assignment_2_XG

Dependencies:   FatFileSystem MCP23017 WattBob_TextLCD mbed

Fork of Assignment_2_herpe by Xavier Herpe

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /**
00002  * Main class for the project.
00003  * The main class instantiates all the tasks and schedules them
00004  * correctly using the TaskManager object.
00005  *
00006  * As writing to the SDCard occasionally hits +50ms in timing, there was several issue
00007  * with the schedule purposed in the original assignment. As a result the timings have changed.
00008  * 
00009  * Action 2 (reading digital values) have been discarded. The values are only used
00010  * in the Action 5, as a result we might as well read them "Just In Time". 
00011  * However if desired it could have been scheduled starting at 600ms with a freqency of 600ms
00012  * 
00013  * The schedule is as follows:
00014  * Action 1 (frequency)           1200ms
00015  * Action 2 (get digital input)   disabled, see above
00016  * Action 3 (read analog in)      600ms
00017  * Action 4 (Print to LCD)        1200ms
00018  * Action 5 (checks)              600ms
00019  * Action 5.1 (binary counting)   1800ms
00020  * Action 6 (SDCard)              4800ms
00021  *
00022  * Author: Jacob Baungard Hansen
00023  */
00024 
00025 #include "task.h"
00026 #include "lcd_helper.h"
00027 #include "demo_task.h"
00028 #include "task_manager.h"
00029 #include "state.h"
00030 #include "lcd_task.h"
00031 #include "update_analog_task.h"
00032 #include "check_task.h"
00033 #include "freq_task.h"
00034 #include "SDFileSystem.h"
00035 #include "sdcard_task.h"
00036 
00037 int main() {
00038 
00039     LCDHelper * lcd_helper = new LCDHelper();
00040     
00041     State * state = new State(); 
00042     
00043     TaskManager * tm = new TaskManager(100, lcd_helper);
00044     
00045     UpdateAnalogTask * analog_task  = new UpdateAnalogTask(100, 600, state);
00046     CheckTask * check_task = new CheckTask(200, 600, state, tm);
00047     FrequencyTask * freq_task = new FrequencyTask(300, 1200, state);
00048     LCDTask * lcd_task = new LCDTask(400, 2400, lcd_helper, state);
00049     SDCardTask * sd_task = new SDCardTask(4800, 4800, state);
00050     
00051     tm->add_task(check_task);
00052     tm->add_task(analog_task);
00053     tm->add_task(lcd_task);
00054     tm->add_task(freq_task);
00055     tm->add_task(sd_task);
00056     
00057     tm->start();
00058     
00059     delete lcd_helper;
00060     delete lcd_task;
00061     delete analog_task;
00062     delete freq_task;
00063     delete sd_task;
00064     delete tm;  
00065 
00066 }