Subversion Repositories HomeAutomation

Rev

Rev 931 | Rev 1005 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1.  
  2. #include "act_ks0108.h"
  3.  
  4. static unsigned char Splash_left[] PROGMEM = {
  5. 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf,0xe7,0x3,0xf1,0xfa,0xab,0x73,0xb5,0x35,0x36,0x6e,0xfe,0xfe,0xfe,0x6e,0xb4,0x35,0x35,0x71,0xab,0xfb,0xf2,0xf0,0x3,0xf,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0x7,0xff,//Line 1
  6. 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0xff,0xfc,0xe3,0x1f,0xbf,0x7f,0xfe,0xfe,0xff,0xbf,0x77,0x77,0x77,0xbf,0xff,0xfe,0xfe,0xff,0x7f,0x3f,0xdf,0xe3,0xfc,0xfc,0x81,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0xff,//Line 2
  7. 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x1f,0x87,0xd9,0xdc,0xdf,0x7,0x1,0xc,0x2f,0x2f,0x76,0x76,0x79,0x7d,0xfb,0xfb,0xfb,0xfb,0x7d,0x79,0x76,0x36,0xf,0xc,0x9,0x7,0xf,0xdf,0xdf,0xd8,0xa7,0x8f,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0xff,//Line 3
  8. 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf,0xf0,0xfe,0xff,0xff,0xff,0x7,0x3,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3,0x7,0xff,0xff,0xff,0xff,0xf0,0xf,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0xff,//Line 4
  9. 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x83,0xfc,0xff,0xff,0xff,0xff,0x9f,0xe0,0xf8,0xf0,0xf0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf0,0xf0,0xf8,0xe0,0x1f,0xff,0xff,0xff,0xff,0xfc,0x83,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0xff,//Line 5
  10. 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0xff,0xff,0xff,0x1f,0xe1,0xfe,0xff,0xff,0x7f,0x1f,0x7,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7,0x1f,0x7f,0xff,0xff,0xfe,0xe1,0x1f,0xff,0xff,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0x3,0xb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xb,0x3,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfb,0xfc,0xff,//Line 6
  11. 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7,0xf8,0xff,0xff,0xf,0xf0,0xff,0xff,0xf,0x13,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x13,0xf,0xff,0xff,0xf0,0xf,0xff,0xff,0xf8,0x7,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,//Line 7
  12. 0xff,0xbf,0x5f,0x5f,0x6f,0x77,0x79,0x7e,0x9f,0x7f,0x87,0xf8,0xff,0xff,0xff,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xf8,0xf8,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0xff,0xff,0xff,0xf8,0x87,0x7f,0x9f,0x7e,0x79,0x77,0x6f,0x5f,0x5f,0xbf,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x0,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x0,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff//Line 7
  13. };
  14. uint16_t ixa = 0;
  15. uint8_t jxa = 0;
  16. uint16_t sensor_Temperature = 12.7*(2<<(SNS_DECPOINT_VOLTAGE-1));
  17.  
  18.  
  19. void numtoascii( int16_t num, char **str );
  20. void signedtoascii(int16_t num, uint8_t decimalplace, char *string, uint8_t numberofdecimals);
  21. void unsignedtoascii(uint16_t num, uint8_t decimalplace, char *string, uint8_t numberofdecimals);
  22.  
  23. void act_ks0108_Init(void)
  24. {
  25.     ///TODO: Initialize hardware etc here
  26.     DDRC |= (1<<PC0);
  27.     PORTC |= (1<<PC0);
  28.  
  29.     glcdPowerOn();
  30.  
  31.     glcdSetXY(0,0);
  32.     glcdSetXY(0,0);
  33.     glcdSetXY(0,0);
  34.  
  35.     for (jxa = 0; jxa< 8; jxa++){
  36.         glcdSetXY(0,jxa);
  37.         for (ixa = 0; ixa < 128; ixa++){
  38.             glcdWriteData((uint8_t)pgm_read_byte((uint16_t)&Splash_left+ixa+jxa*128));
  39.         }
  40.     }
  41.  
  42. }
  43.  
  44. void act_ks0108_Process(void)
  45. {
  46.     ///TODO: Stuff that needs doing is done here
  47. }
  48.  
  49. void act_ks0108_HandleMessage(StdCan_Msg_t *rxMsg)
  50. {
  51.     static uint8_t saer=0;
  52.     saer++;
  53.     if (saer>6) {
  54.         //glcdSetXY(0,0);
  55.         //glcdPutStr("rad0.1");
  56.         glcdSetXY(78,1);
  57.         glcdPutStr("Hej!");
  58.         glcdSetXY(78,2);
  59.         glcdPutStr("28 grader");
  60.         //glcdSetXY(3,3);
  61.         //glcdPutStr("rad3.4");
  62.         glcdSetXY(78,4);
  63.         glcdPutStr("En för lång text");
  64.         /*glcdSetXY(5,5);
  65.         glcdPutStr("rad5.6");
  66.         glcdSetXY(6,6);
  67.         glcdPutStr("rad6.7");
  68.         glcdSetXY(7,7);
  69.         glcdPutStr("rad7.8");
  70.         glcdSetXY(8,8);
  71.         glcdPutStr("rad7.8");
  72.         */
  73.  
  74.     }
  75.     /*
  76.     if (    StdCan_Ret_class(rxMsg->Header) == CAN_CLASS_MODULE_DEF && ///TODO: Change this to the actual class type
  77.         StdCan_Ret_direction(rxMsg->Header) == DIR_TO_OWNER &&
  78.         rxMsg->Header.ModuleType == CAN_TYPE_MODULE_def_default && ///TODO: Change this to the actual module type
  79.         rxMsg->Header.ModuleId == act_ks0108_ID)
  80.     {
  81.         switch (rxMsg->Header.Command)
  82.         {
  83.         case CAN_CMD_MODULE_DUMMY:
  84.         ///TODO: Do something dummy
  85.         break;
  86.         }
  87.     }
  88.     */
  89. }
  90.  
  91. void act_ks0108_List(uint8_t ModuleSequenceNumber)
  92. {
  93.     StdCan_Msg_t txMsg;
  94.  
  95.     StdCan_Set_class(txMsg.Header, CAN_MODULE_CLASS_ACT);
  96.     StdCan_Set_direction(txMsg.Header, DIRECTIONFLAG_FROM_OWNER);
  97.     txMsg.Header.ModuleType = CAN_MODULE_TYPE_ACT_KS0108;
  98.     txMsg.Header.ModuleId = act_ks0108_ID;
  99.     txMsg.Header.Command = CAN_MODULE_CMD_GLOBAL_LIST;
  100.     txMsg.Length = 6;
  101.  
  102.     txMsg.Data[0] = NODE_HW_ID_BYTE0;
  103.     txMsg.Data[1] = NODE_HW_ID_BYTE1;
  104.     txMsg.Data[2] = NODE_HW_ID_BYTE2;
  105.     txMsg.Data[3] = NODE_HW_ID_BYTE3;
  106.  
  107.     txMsg.Data[4] = NUMBER_OF_MODULES;
  108.     txMsg.Data[5] = ModuleSequenceNumber;
  109.  
  110.     StdCan_Put(&txMsg);
  111. }
  112.  
  113. //� la pengi. Skall libbifieras.
  114.     void numtoascii( int16_t num, char **str ) {
  115.         if( num==0 ) return;
  116.         numtoascii( num/10, str );
  117.         **str = '0' + (num%10);
  118.         (*str)++;
  119.     }
  120.  
  121.     void signedtoascii(int16_t num, uint8_t decimalplace, char *string, uint8_t numberofdecimals){ //decimalplace is number of decimals
  122.         uint8_t i;
  123.  
  124.         if( num<0 ) {
  125.             *(string++) = '-';
  126.             num = -num;
  127.         }
  128.         numtoascii(num>>decimalplace, &string );
  129.         if(numberofdecimals!=0) *(string++) = '.';
  130.         for(i=0;i<numberofdecimals;i++) {
  131.             num %= 1<<decimalplace;
  132.             num *= 10;
  133.             *(string++) = '0' + (num>>decimalplace);
  134.         }
  135.         *(string++) = 0;
  136.     }
  137.  
  138.     void unsignedtoascii(uint16_t num, uint8_t decimalplace, char *string, uint8_t numberofdecimals){ //decimalplace is number of decimals
  139.         uint8_t i;
  140.         numtoascii(num>>decimalplace, &string );
  141.         if(numberofdecimals!=0) *(string++) = '.';
  142.         for(i=0;i<numberofdecimals;i++) {
  143.             num %= 1<<decimalplace;
  144.             num *= 10;
  145.             *(string++) = '0' + (num>>decimalplace);
  146.         }
  147.         *(string++) = 0;
  148.     }
  149.