/*********************************************************************
*
* Main application
*
*********************************************************************
* FileName: $HeadURL: https://svn.auml.se/svn/HomeAutomation/trunk/EmbeddedSoftware/PIC/canLCD/Source/Main.c $
* Last changed: $LastChangedDate: 2007-03-04 15:13:16 +0100 (Sun, 04 Mar 2007) $
* By: $LastChangedBy: johboh $
* Revision: $Revision: 359 $
********************************************************************/
#include <compiler.h>
#include <stackTasks.h>
#include <Tick.h>
#include <funcdefs.h>
#include <CAN.h>
#include "..\canBoot\Include\boot.h"
#ifdef USE_GLCD
#include "glcd.h"
#endif
#ifdef USE_ADC
#include <adc.h>
#endif
#ifdef USE_GLCD
const rom BYTE pic[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x60,0x90,0x90,0x10,0x30,
0x00,0x10,0xF0,0x80,0x80,0x00,0x00,0x00,
0x00,0x80,0x80,0x00,0x00,0x80,0x80,0x80,
0x80,0x00,0x00,0x00,0x80,0x80,0x8C,0x80,
0x00,0x10,0xF0,0x80,0x80,0x00,0x00,0x00,
0x00,0x80,0x80,0x00,0x00,0x80,0x80,0x80,
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x30,0x10,0xF0,0x10,0x30,0x00,0xE0,
0x10,0x10,0x10,0xE0,0x00,0x10,0xF0,0x90,
0x90,0x60,0x00,0x70,0x80,0xF0,0x8C,0x70,
0x00,0x00,0x80,0x70,0xC0,0x00,0x00,0x10,
0x70,0x80,0x70,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x0C,0x08,0x08,0x09,0x06,
0x00,0x08,0x0F,0x08,0x00,0x0F,0x08,0x00,
0x07,0x0A,0x0A,0x0B,0x00,0x08,0x0F,0x08,
0x00,0x0F,0x08,0x00,0x08,0x08,0x09,0x08,
0x00,0x08,0x0F,0x08,0x00,0x0F,0x08,0x00,
0x07,0x0A,0x0A,0x0B,0x00,0x08,0x0F,0x08,
0x00,0x0F,0x08,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x08,0x0F,0x08,0x00,0x00,0x07,
0x08,0x08,0x08,0x07,0x00,0x08,0x0F,0x08,
0x00,0x00,0x00,0x00,0x0F,0x00,0x0F,0x00,
0x00,0x08,0x0F,0x02,0x03,0x0E,0x08,0x00,
0x08,0x0F,0x08,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x03,0x81,0xFF,0x81,0x03,0x00,0x00,
0x70,0xA8,0xA8,0xB0,0x00,0x00,0x70,0x88,
0x88,0x98,0x00,0x81,0xFF,0x88,0x08,0xF0,
0x80,0x88,0xF8,0x88,0x08,0xF0,0x80,0x00,
0x70,0x88,0x88,0x70,0x00,0x81,0x81,0xFF,
0x80,0x80,0x00,0x00,0x70,0x88,0x88,0x70,
0x00,0x00,0xD0,0xA8,0xA8,0x98,0x08,0x08,
0x38,0xC8,0x60,0x18,0x08,0x00,0x00,0x00,
0x00,0x00,0x00,0x7E,0x81,0x81,0x81,0x43,
0x00,0x00,0x70,0x88,0x88,0x70,0x00,0x00,
0x80,0x00,0x00,0x00,0x00,0x00,0x80,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x81,0xFF,0x81,0x80,0x80,0xC0,0x00,
0x08,0x7E,0x88,0x80,0x00,0x00,0x70,0x88,
0x89,0xFF,0x80,0x00,0x80,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0x02,0x02,0x01,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x02,0x02,0x01,0x02,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x02,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x81,
0xC0,0xFF,0x0F,0xF0,0x89,0x89,0x8B,0x70,
0x81,0x7E,0x00,0x42,0x00,0x76,0x89,0x89,
0xFF,0x89,0x89,0x76,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0x81,0x80,0x80,0x0F,0xFF,0x00,0x81,
0x00,0x78,0x81,0x81,0x81,0x89,0x89,0x76,
0x89,0x76,0x00,0x81,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
const rom BYTE pic2[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0x03,0x00,0x00,0x00,
0x00,0x00,0x00,0xc0,0x0f,0x00,0x00,0x00,
0x00,0x00,0x00,0xc0,0x3f,0x00,0x00,0x00,
0x00,0x00,0x00,0xe0,0xff,0x00,0x00,0x00,
0x00,0x00,0x00,0xe0,0xff,0x03,0x00,0x00,
0x00,0x00,0x00,0xe0,0xff,0xcf,0x03,0x00,
0x00,0x00,0x00,0x00,0xff,0xff,0x03,0x00,
0x00,0x00,0x00,0x00,0xfc,0xff,0x03,0x00,
0x00,0x00,0x00,0x00,0xf0,0xff,0x03,0x00,
0x00,0x00,0x00,0x00,0xc0,0xff,0x01,0x00,
0x00,0x00,0x00,0x00,0x00,0xfe,0x00,0x00,
0x00,0x00,0x00,0x80,0x1f,0x78,0x00,0x00,
0x00,0x00,0x00,0xe0,0xff,0x00,0x00,0x00,
0x00,0x00,0x00,0xe0,0xff,0x03,0x00,0x00,
0x00,0x00,0x00,0xf0,0xff,0x07,0x00,0x00,
0x00,0x00,0x00,0xf0,0xff,0x0f,0x00,0x00,
0x00,0x00,0x00,0xf0,0xfe,0x1f,0x00,0x00,
0x00,0x00,0x00,0xf0,0xf1,0x1f,0x00,0x00,
0x00,0x00,0x00,0xf0,0xc7,0x1f,0x00,0x00,
0x00,0x00,0x00,0xf0,0x3f,0x1f,0x00,0x00,
0x00,0x00,0x00,0xf0,0xff,0x0f,0x00,0x00,
0x00,0x00,0x00,0xf0,0xff,0x0f,0x00,0x00,
0x00,0x00,0x00,0xe0,0xff,0x0f,0x00,0x00,
0x00,0x00,0xc0,0x83,0xff,0x07,0x00,0x00,
0x00,0x00,0xc0,0x3f,0xfc,0x03,0x00,0x00,
0x00,0x00,0xc0,0xff,0x01,0x00,0x00,0x00,
0x00,0x00,0xc0,0xff,0x1f,0x00,0x00,0x00,
0x00,0x00,0xe0,0xff,0xff,0x01,0x00,0x00,
0x00,0x00,0xe0,0xff,0xff,0x03,0x00,0x00,
0x00,0x00,0x00,0xff,0xff,0x03,0x00,0x00,
0x00,0x00,0x00,0xff,0xff,0x01,0x00,0x00,
0x00,0x00,0x00,0x0f,0xfe,0x01,0x00,0x00,
0x00,0x00,0x80,0x0f,0xe0,0x01,0x00,0x00,
0x00,0x00,0x80,0x7f,0x00,0x00,0x00,0x00,
0x00,0x00,0x80,0xff,0x0f,0x00,0x00,0x00,
0x00,0x00,0x80,0xff,0xff,0x00,0x00,0x00,
0x00,0x00,0x80,0xff,0xff,0x00,0x00,0x00,
0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,
0x00,0x00,0x00,0xfe,0xff,0x00,0x00,0x00,
0x00,0x00,0x78,0x80,0x7f,0x00,0x00,0x00,
0x00,0x00,0xf8,0x1f,0x60,0x00,0x00,0x00,
0x00,0x00,0xf8,0xff,0x0f,0x00,0x00,0x00,
0x00,0x00,0xf8,0xff,0x7f,0x00,0x00,0x00,
0x00,0x00,0xfc,0xff,0x7f,0x00,0x00,0x00,
0x00,0x00,0xfc,0xff,0x7f,0x00,0x00,0x00,
0x00,0x00,0xe0,0xff,0x3f,0x00,0x00,0x00,
0x00,0x00,0xe0,0xc1,0x3f,0x00,0x00,0x00,
0x00,0x00,0xe0,0x07,0x1c,0x00,0x00,0x00,
0x00,0x00,0xe0,0xff,0x3f,0x00,0x00,0x00,
0x00,0x00,0xe0,0xff,0x3f,0x00,0x00,0x00,
0x00,0x00,0xe0,0xff,0x3f,0x00,0x00,0x00,
0x00,0x00,0xe0,0xff,0x3f,0x00,0x00,0x00,
0x00,0x00,0xc0,0xff,0x1f,0x00,0x00,0x00,
0x00,0x00,0x00,0xe0,0x0f,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x80,0xff,0x07,0x00,0x00,0x00,
0x00,0x00,0xc0,0xff,0x0f,0x00,0x00,0x00,
0x00,0x00,0xe0,0xff,0x1f,0x00,0x00,0x00,
0x00,0x00,0xe0,0xff,0x1f,0x00,0x00,0x00,
0x00,0x00,0xe0,0xff,0x1f,0x00,0x00,0x00,
0x00,0x00,0xf0,0xff,0x1f,0x00,0x00,0x00,
0x00,0x00,0xf0,0x01,0x1e,0x00,0x00,0x00,
0x00,0x00,0xe0,0xff,0x1f,0x00,0x00,0x00,
0x00,0x00,0xe0,0xff,0x1f,0x00,0x00,0x00,
0x00,0x00,0xe0,0xff,0x1f,0x00,0x00,0x00,
0x00,0x00,0xc0,0xff,0x0f,0x00,0x00,0x00,
0x00,0x00,0xc0,0xff,0x07,0x00,0x00,0x00,
0x00,0x00,0x00,0x7f,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x00,
0x00,0x00,0xe0,0xff,0x3f,0x00,0x00,0x00,
0x00,0x00,0xfc,0xff,0x3f,0x00,0x00,0x00,
0x00,0x00,0xfc,0xff,0x3f,0x00,0x00,0x00,
0x00,0x00,0xfc,0xff,0x3f,0x00,0x00,0x00,
0x00,0x00,0xfc,0xff,0x3f,0x00,0x00,0x00,
0x00,0x00,0xfc,0xff,0x00,0x00,0x00,0x00,
0x00,0x00,0xfc,0x03,0x00,0x00,0x00,0x00,
0x00,0x00,0xc0,0x03,0x7c,0x00,0x00,0x00,
0x00,0x00,0xc0,0xff,0x7f,0x00,0x00,0x00,
0x00,0x00,0xc0,0xff,0x7f,0x00,0x00,0x00,
0x00,0x00,0xc0,0xff,0x7f,0x00,0x00,0x00,
0x00,0x00,0xc0,0xff,0x7f,0x00,0x00,0x00,
0x00,0x00,0xc0,0xff,0x7f,0x00,0x00,0x00,
0x00,0x00,0x80,0xff,0x01,0x00,0x00,0x00,
0x00,0x00,0x00,0x06,0xf8,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,
0x00,0x00,0x00,0xfc,0xff,0x00,0x00,0x00,
0x00,0x00,0xf0,0xff,0xff,0x01,0x00,0x00,
0x00,0x00,0xf0,0xff,0xff,0x01,0x00,0x00,
0x00,0x00,0xf0,0xff,0x37,0x00,0x00,0x00,
0x00,0x00,0xe0,0xff,0x00,0x00,0x00,0x00,
0x00,0x00,0xe0,0x0f,0x00,0x00,0x00,0x00,
0x00,0x00,0xe0,0x01,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x0e,0x00,0x00,
0x00,0x00,0x00,0x00,0xc0,0x0f,0x00,0x00,
0x00,0x00,0x00,0x00,0xc0,0x0f,0x00,0x00,
0x00,0x00,0x00,0x80,0xc7,0x0f,0x00,0x00,
0x00,0x00,0x00,0xc0,0xc7,0x0f,0x00,0x00,
0x00,0x00,0x00,0xc0,0x8f,0x07,0x00,0x00,
0x00,0x00,0x00,0xc0,0x8f,0x01,0x00,0x00,
0x00,0x00,0x00,0x80,0x3f,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0x7f,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xf8,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xf8,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xf0,0x61,0x00,0x00,
0x00,0x00,0x00,0x00,0xf0,0xf1,0x00,0x00,
0x00,0x00,0x00,0x00,0xe0,0xf0,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xfe,0x01,0x00,
0x00,0x00,0x00,0x00,0x80,0xff,0x01,0x00,
0x00,0x00,0x00,0x00,0xe0,0xff,0x01,0x00,
0x00,0x00,0x00,0xe0,0xf8,0xff,0x00,0x00,
0x00,0x00,0x00,0xe0,0xff,0x7f,0x00,0x00,
0x00,0x00,0x00,0xe0,0xff,0x1f,0x00,0x00,
0x00,0x00,0x00,0xe0,0xff,0x07,0x00,0x00,
0x00,0x00,0x00,0xc0,0xff,0x01,0x00,0x00,
0x00,0x00,0x00,0xc0,0x7f,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0x1f,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
const rom BYTE pic3[] = {
'\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff',
'\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff',
'\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff',
'\xf9','\xff','\xff','\xff','\xff','\xff','\xff','\xff',
'\xe1','\xff','\xff','\xff','\xff','\xff','\xff','\xff',
'\xed','\xff','\xff','\xff','\xff','\xff','\xff','\xff',
'\xdd','\xff','\xff','\xff','\xff','\xff','\xff','\xff',
'\x9d','\xff','\xff','\xff','\xff','\xff','\xff','\xff',
'\xb9','\xff','\xff','\xff','\xff','\xff','\xff','\xff',
'\xbb','\xff','\xff','\x07','\xfc','\xff','\xff','\xff',
'\x7b','\xfe','\xff','\xfb','\xfb','\xff','\xff','\xff',
'\xfb','\xfe','\xff','\xf9','\xf3','\xff','\xff','\xff',
'\xf3','\xfc','\xff','\xfd','\xe7','\xff','\xff','\xff',
'\x07','\xfc','\xff','\xfc','\xef','\xff','\xff','\xff',
'\xf7','\xfd','\x7f','\xfe','\xdf','\xff','\xff','\xff',
'\xf7','\xfd','\x7f','\xff','\xdf','\xff','\xff','\xff',
'\xf7','\xfd','\x7f','\xff','\xbf','\xff','\xff','\xff',
'\xf7','\xfd','\x7f','\x1f','\x70','\xff','\xff','\xff',
'\xf7','\x3d','\x00','\xe7','\x67','\xff','\xff','\xff',
'\xf7','\xdd','\x7f','\xfb','\x6f','\xff','\xff','\xff',
'\xf7','\xe5','\x7f','\xfb','\xef','\xfe','\xff','\xff',
'\xf7','\xf9','\x7f','\xfb','\xef','\xfe','\xff','\xff',
'\xf7','\xfa','\x7f','\xfb','\xef','\xfd','\xff','\xff',
'\xf7','\xfc','\x7f','\xfb','\xef','\xfd','\xff','\xff',
'\xf7','\xfc','\x7f','\xfb','\xef','\xfb','\xff','\xff',
'\xf7','\xfc','\x7f','\xfb','\xef','\xfb','\xff','\xff',
'\xf7','\xfe','\x7f','\xf9','\xef','\xfb','\xff','\xff',
'\xf7','\xfe','\x7f','\xf9','\xef','\x87','\xff','\xff',
'\xf7','\xfe','\x7f','\xf9','\xef','\xb7','\xff','\xff',
'\xf7','\xfe','\x7f','\xf9','\xf7','\xb7','\xff','\xff',
'\xf7','\xfc','\x7f','\xf3','\xf7','\xb7','\xff','\xff',
'\xf7','\xfc','\x7f','\xe7','\xfb','\xb7','\xff','\xff',
'\xf7','\xfa','\x7f','\x1f','\xfc','\xb7','\xff','\xff',
'\xf7','\x7a','\x78','\xff','\xff','\xb7','\xff','\xff',
'\xf7','\x36','\x70','\xff','\xff','\x37','\xff','\xff',
'\xf7','\x36','\x70','\xff','\xff','\x77','\xff','\xff',
'\xf7','\x4e','\x70','\xff','\xff','\x77','\xff','\xff',
'\xf7','\x1e','\x00','\xff','\xff','\x77','\xff','\xff',
'\xf7','\xfe','\x7f','\xff','\xff','\x77','\xff','\xff',
'\xf7','\xfe','\x7f','\xff','\xff','\x77','\xff','\xff',
'\xf7','\xfe','\x7f','\xff','\xff','\x77','\xff','\xff',
'\xf7','\xfe','\x7f','\xff','\xff','\x77','\xff','\xff',
'\xf7','\xfe','\x7f','\xff','\xff','\x77','\xff','\xff',
'\xf7','\xfe','\x7f','\xff','\xff','\x77','\xff','\xff',
'\xf7','\xfe','\x7f','\xff','\xff','\x77','\xfe','\xff',
'\xf7','\xfe','\x7f','\xff','\xff','\x77','\xf0','\xff',
'\xf7','\xfe','\x7f','\xff','\xff','\x77','\xe7','\xff',
'\xf7','\xfe','\x7f','\xff','\xff','\x77','\xef','\xff',
'\xf7','\xfe','\x7f','\xff','\xff','\x77','\xcf','\xff',
'\xf7','\xfe','\x7f','\xff','\xff','\x77','\x3f','\xff',
'\xf7','\xfe','\x7f','\xff','\xff','\x77','\x7f','\xf8',
'\xf7','\xfe','\x7f','\xff','\xff','\x77','\xff','\xe7',
'\xf7','\xfe','\x7f','\xff','\xff','\x77','\xff','\xef',
'\xf7','\xfe','\x7f','\xff','\xff','\x77','\xff','\xef',
'\xf7','\xfe','\x7f','\xff','\xff','\x77','\xff','\xe0',
'\xf7','\xfe','\x7f','\xff','\xff','\x77','\xff','\xfe',
'\xf7','\xfe','\x7f','\xff','\xff','\x77','\xc0','\xfe',
'\xf7','\xfe','\x7f','\xff','\xff','\x7b','\xdf','\xc0',
'\xf7','\xfe','\x7f','\xff','\xff','\x7b','\xdf','\x9f',
'\xf7','\xfe','\x7f','\xff','\xff','\x7b','\xdf','\xbf',
'\xf7','\xfc','\x7f','\xff','\xff','\x7b','\xdf','\xbf',
'\xf7','\xfd','\x7f','\xff','\xff','\x7b','\xdf','\x81',
'\xf7','\xfd','\x7f','\xff','\xff','\x7b','\xdf','\xfd',
'\xf7','\xfd','\x7f','\xff','\xff','\x7b','\xdf','\xfd',
'\xf7','\xfd','\x7f','\x3f','\xf8','\x3d','\xdf','\xfd',
'\xf7','\x0d','\x00','\xcf','\xfb','\xbd','\xdf','\xfd',
'\xf7','\x22','\x60','\xe7','\xf7','\x9d','\xdf','\xfd',
'\xf7','\x38','\x70','\xf7','\xf7','\xdd','\xdf','\xfd',
'\xf7','\xfc','\x7f','\xf3','\xf7','\xcd','\xdf','\xfd',
'\xf7','\xfc','\x7f','\xfb','\xf7','\xe5','\xdf','\xfd',
'\xf7','\xfe','\x7f','\xfb','\xf7','\xf8','\xdf','\xfd',
'\xf7','\xfe','\x7f','\xfb','\xf7','\xfe','\xdf','\xfd',
'\xf7','\xfe','\x7f','\xfb','\xf7','\xfe','\xdf','\xfd',
'\xf7','\xfe','\x7f','\xfb','\xf7','\xfe','\xdf','\xfd',
'\xf7','\xfc','\x7f','\xfb','\xf7','\xfe','\xdf','\xfd',
'\xf7','\xfc','\x7f','\xf3','\xf7','\xfe','\xdf','\xfd',
'\xf7','\xf8','\x7f','\xf3','\xf7','\xfe','\xdf','\xfd',
'\xf3','\xf2','\x7f','\xf3','\xf7','\xfe','\xdf','\xfd',
'\x03','\xe6','\x7f','\xf3','\xf8','\xfe','\xdf','\xfd',
'\xfb','\xce','\x7f','\x03','\xfe','\xfe','\xdf','\xfd',
'\xfb','\x1e','\x7f','\xfb','\xff','\xfe','\xdf','\xfd',
'\xfb','\x7e','\x00','\xff','\xff','\xfe','\xdf','\xfd',
'\xfb','\xfe','\x7f','\xff','\xff','\xfe','\xdf','\xfd',
'\xf9','\xfe','\x7f','\xff','\x7f','\xfe','\xdf','\xfd',
'\x7d','\xfe','\x7f','\xff','\x7f','\xff','\xdf','\xfd',
'\x05','\xff','\x7f','\xff','\x7f','\xff','\xdf','\xfd',
'\xf9','\xff','\x3f','\xff','\x3f','\xff','\xdf','\xfd',
'\xff','\xff','\x7f','\xff','\xbf','\xff','\xdf','\xfd',
'\xff','\xff','\x7f','\xfe','\xdf','\xff','\xdf','\xfd',
'\xff','\xff','\xff','\xfe','\xcf','\xff','\xdf','\xfd',
'\xff','\xff','\xff','\x00','\xe0','\xff','\xdf','\xfd',
'\xff','\xff','\xff','\xff','\xff','\xff','\xdf','\xfd',
'\xff','\xff','\xff','\xff','\xff','\xff','\xdf','\xfd',
'\xff','\xff','\xff','\xff','\xff','\xff','\xdf','\xfd',
'\xff','\xff','\xff','\xff','\xff','\xff','\xdf','\xfd',
'\xff','\xff','\xff','\xff','\xff','\xff','\xdf','\xfd',
'\xff','\xff','\xff','\xff','\xff','\xff','\xdf','\xfd',
'\xff','\xff','\xff','\xff','\xff','\xff','\xdf','\xe1',
'\xff','\xff','\xff','\xff','\xff','\xff','\xdf','\xdf',
'\xff','\xff','\xff','\xff','\xff','\xff','\xdf','\xdf',
'\xff','\xff','\xff','\xff','\xff','\xff','\xdf','\xbf',
'\xff','\xff','\xff','\xff','\xff','\xff','\xdf','\x81',
'\xff','\xff','\xff','\xff','\xff','\xff','\xdf','\xfc',
'\xff','\xff','\xff','\xff','\xff','\xff','\xdf','\xfe',
'\xff','\xff','\xff','\xff','\xff','\xff','\xdf','\xfe',
'\xff','\xff','\xff','\xff','\xff','\xff','\xbf','\xe0',
'\xff','\xff','\xff','\xff','\xff','\xff','\xbf','\xdf',
'\xff','\xff','\xff','\xff','\xff','\xff','\xbf','\xdf',
'\xff','\xff','\xff','\xff','\xff','\xff','\x3f','\xdf',
'\xff','\xff','\xff','\xff','\xff','\xff','\x3f','\xc0',
'\xff','\xff','\xff','\xff','\xff','\xff','\xbf','\xff',
'\xff','\xff','\xff','\xff','\xff','\xff','\xbf','\xff',
'\xff','\xff','\xff','\xff','\xff','\xff','\xbf','\xff',
'\xff','\xff','\xff','\xff','\xff','\xff','\xbf','\xff',
'\xff','\xff','\xff','\xff','\xff','\xff','\xbf','\xff',
'\xff','\xff','\xff','\xff','\xff','\xff','\xbf','\xff',
'\xff','\xff','\xff','\xff','\xff','\xff','\x7f','\xff',
'\xff','\xff','\xff','\xff','\xff','\xff','\x7f','\xff',
'\xff','\xff','\xff','\xff','\xff','\xff','\x7f','\xff',
'\xff','\xff','\xff','\xff','\xff','\xff','\x7f','\xce',
'\xff','\xff','\xff','\xff','\xff','\xff','\xbf','\xc0',
'\xff','\xff','\xff','\xff','\xff','\xff','\xbf','\xfd',
'\xff','\xff','\xff','\xff','\xff','\xff','\xbf','\xfd',
'\xff','\xff','\xff','\xff','\xff','\xff','\xbf','\xfb',
'\xff','\xff','\xff','\xff','\xff','\xff','\xbf','\xf3',
'\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xf7',
'\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff',
'\xff','\xff','\xff','\xff','\xff','\xff','\xff','\xff'
};
rom BYTE str[] = "Johboh är bäst! ;)";
#endif
static void mainInit(void);
void main()
{
// Inits
mainInit();
canInit();
#ifdef USE_GLCD
GLCD_CS_IO = 0;
glcdInit();
GLCD_CS_IO = 1;
#endif
#ifdef USE_ADC
adcInit(TRUE,0b1011);
#endif
while(1)
{
TICK currentTick = tickGet();
static TICK tick_led = 0;
static TICK tick_pic = 0;
static TICK tick_temperature = 0;
static TICK tick_door = 0;
static TICK bounce_door = 0;
static BYTE lastDoorValue = DOOR_CLOSED;
static BOOL getNewTemperature = TRUE;
static BYTE picCnt = 0;
if ((currentTick-tick_led)>(1*TICK_1S))
{
LED0_IO=~LED0_IO;
tick_led = currentTick;
}
#ifdef USE_GLCD
if ((currentTick-tick_pic)>(5*TICK_1S))
{
CAN_PACKET outCp;
GLCD_CS_IO = 0;
glcdSetStartLine(0x00);
glcdClearScr();
if (picCnt==0) glcdDisplayPic(0,0,pic);
else if (picCnt==1) glcdDisplayPic(0,0,pic2);
else if (picCnt==2) glcdPutrs(0,0,str);
else if (picCnt==3) glcdDisplayPic(0,0,pic3);
GLCD_CS_IO = 1;
outCp.type = ptPGM;
outCp.pgm.class = pcSENSOR;
outCp.pgm.id = pstIR;
outCp.length = 1;
outCp.data[0] = picCnt;
while(!canSendMessage(outCp,PRIO_HIGH));
if (++picCnt>3) picCnt=0;
tick_pic = currentTick;
}
#endif
#ifdef USE_ADC
if ((currentTick-tick_temperature)>(2*TICK_1S) && getNewTemperature==TRUE) // Each 2 second, read temperature.
{
adcConvert(TEMPERATURE_OUTSIDE);
getNewTemperature=FALSE;
tick_temperature = currentTick;
}
#endif
#ifdef USE_ADC
if (adcDone()) // Has temperature, send it to the bus
{
CAN_PACKET outCp;
BYTE decimal;
signed char tenth;
temperatureRead(&tenth,&decimal);
outCp.type=ptPGM;
outCp.pgm.class =pcSENSOR;
outCp.pgm.id = pstTEMP_DOOR_OUTSIDE;
outCp.length =2;
outCp.data[1] = tenth; // signed 10 an 1 decimal.
outCp.data[0] = decimal; // Decimal value, 0-9
while(!canSendMessage(outCp,PRIO_HIGH));
getNewTemperature=TRUE;
tick_temperature = currentTick;
}
#endif
#ifdef USE_DOOR_SW
if ((currentTick-bounce_door)>(3*TICK_100MS) && lastDoorValue != SW1_IO)
{
lastDoorValue = SW1_IO;
tick_door = 0;
bounce_door = currentTick;
}
if ((currentTick-tick_door)>(3*TICK_1S))
{
CAN_PACKET outCp;
outCp.type = ptPGM;
outCp.pgm.class = pcSENSOR;
outCp.pgm.id = pstDOOR_OUTSIDE;
outCp.length = 1;
outCp.data[0] = (SW1_IO==DOOR_CLOSED?0:1);
while(!canSendMessage(outCp,PRIO_HIGH));
tick_door = currentTick;
}
#endif
}
}
#pragma interrupt high_isr
void high_isr(void)
{
canISR();
#ifdef USE_ROTARY
if (INTCONbits.INT0IE == 1 && INTCONbits.INT0IF == 1)
{
// ROTARY_A_IO panel (nobuss)
// ROTARY_B_IO panel (nobuss)
static TICK tick_lastRotation = 0;
if ((tickGet()-tick_lastRotation)>(5*TICK_100MS))
{
if (ROTARY_A_IO==1 && ROTARY_B_IO==0)
{
// action
// left
}
else if (ROTARY_A_IO==0 && ROTARY_B_IO==1)
{
// action
// Right
}
tick_lastRotation=tickGet();
}
INTCONbits.INT0IF = 0;
}
#endif
#ifdef USE_ADC
adcISR();
#endif
}
#pragma interrupt low_isr
void low_isr(void)
{
#ifdef USE_PANEL_SW
if (INTCON3bits.INT1IE == 1 && INTCON3bits.INT1IF == 1)
{
// SW0_IO == panel (nobuss)
// ROTARY_SW_IO == panel (nobuss)
TICK currentTick = tickGet();
static TICK tick_lastPanelSw = 0;
static TICK tick_lastRotSw = 0;
if (SW0_IO == 0 && (currentTick-tick_lastPanelSw)>(5*TICK_100MS))
{
// action
tick_lastPanelSw = currentTick;
}
else if (ROTARY_SW_IO == 0 && (currentTick-tick_lastRotSw)>(5*TICK_100MS))
{
// action
tick_lastRotSw = currentTick;
}
INTCON3bits.INT1IF = 0;
}
#endif
}
/*
* Function: mainInit
*
* Input: none
* Output: none
* Pre-conditions: none
* Affects: Se code
* Depends: none.
*/
void mainInit()
{
LED0_TRIS=0;
// Enable Interrupts
INTCONbits.GIEH = 1;
INTCONbits.GIEL = 1;
// Enable interrupt prirority
RCONbits.IPEN=1;
#ifdef USE_ROTARY
ROTARY_A_TRIS = 1;
ROTARY_B_TRIS = 1;
INTCONbits.INT0IF = 0;
INTCONbits.INT0IE = 1;
INTCON2bits.INTEDG0 = 1; // rising
// Always high prio
#endif
#ifdef USE_PANEL_SW
ROTARY_SW_TRIS = 1;
SW0_TRIS = 1;
INTCON3bits.INT1IF = 0;
INTCON3bits.INT1IE = 1;
INTCON2bits.INTEDG1 = 0; // falling
INTCON3bits.INT1IP = 0; // low
#endif
#ifdef USE_DOOR_SW
SW1_TRIS = 1;
#endif
}
/*
* Function: canParse
*
* Input: Received can message
* Output: none
* Pre-conditions: canInit and received packet.
* Affects: Sensors/actuators/etc. See code.
* Depends: none.
*/
void canParse(CAN_PACKET cp)
{
}
// Below are mandantory when using bootloader
// define DEBUG_MODE to use without bootloader.
#ifndef DEBUG_MODE
extern void _startup (void);
#pragma code _RESET_INTERRUPT_VECTOR = RM_RESET_VECTOR
void _reset (void)
{
_asm goto _startup _endasm
}
#pragma code
#endif
#pragma code _HIGH_INTERRUPT_VECTOR = RM_HIGH_INTERRUPT_VECTOR
void _high_ISR (void)
{
_asm GOTO high_isr _endasm
}
#pragma code
#pragma code _LOW_INTERRUPT_VECTOR = RM_LOW_INTERRUPT_VECTOR
void _low_ISR (void)
{
_asm GOTO low_isr _endasm
}
#pragma code