Advertisement
Guest User

Untitled

a guest
May 18th, 2015
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.92 KB | None | 0 0
  1. /**************************************************************************
  2.     Souliss - IR Receiver Hack
  3.  
  4.    
  5.     It use Souliss Speak Easy to make write the sketch even easier.
  6.        
  7. /*************************PINOUT*****************************
  8.  
  9. 3      -  IR HACK
  10.  
  11. */     
  12. /*********************************** HACKS ********************************************/
  13. /****************** IR REMOTE HACK ***********************/
  14.  
  15. #include <IRremote.h>
  16.  
  17. int RECV_PIN = 3;  //This cannot be modified
  18. IRrecv irrecv(RECV_PIN);
  19. decode_results results;
  20.  
  21. /************ IR REMOTE BUTTON DEFINITION ***************/
  22.  
  23. #define DEBUG_IR   0  //This values are long values returned by IRremote library, to get your values enable DEBUG and see results on Serial Port
  24.  
  25. #define B0  16748655
  26. #define B1  16758855
  27. #define B2  16775175
  28. #define B3  16756815
  29. #define B4  16750695
  30. #define B5  16767015
  31. #define B6  16746615
  32. #define B7  16754775
  33. #define B8  16771095
  34. #define B9  16730295
  35. #define B10 16738455
  36. #define B11 16757325
  37. #define B12 16712445
  38. #define B13 16724685
  39. #define B14 16720095
  40. #define B15 16711935
  41. #define B16 16732335
  42. #define B17 16742535
  43. #define B18 16740495
  44. #define B19 16734375
  45. #define B20 16726215
  46. #define B21 16722135
  47. #define B22 16773135
  48. #define B23 16724175
  49. #define B_Repeat    4294967295
  50.  
  51. /******************************** SOULISS CONFIGURATION *******************************************/
  52. #include "bconf/inSketch.h"
  53. #define QC_BOARDTYPE                0x05    //Arduino with ENC28J60 Ethernet Shield
  54. #define QC_GATEWAYTYPE              0x01    //None
  55. #define QC_INTERFACE                0x00    //None
  56.  
  57. #include "Souliss.h"
  58. #include "Typicals.h"
  59. #include "SpeakEasy.h"                      // Is a library to code easy Souliss examples
  60. #include <SPI.h>
  61.  
  62. /********************** NETWORK CONFIGURATION ******************************/
  63. // Define the network configuration
  64. // In the QuickCfg.h file set DEFAULT_BASEIPADDRESS[] = {192,168,1,0}
  65. #define eth_bridge_address  0x0011
  66. #define myvNet_subnet       0xFF00
  67. #define myvNet_supern       0x0000
  68. // defining myvNet_address as 0x0011 (is hexadecimal, in decimal is uqual to 17) gives
  69. // as IP address 192.168.1.17, use this address in SoulissApp
  70.  
  71. /********************************** PIN  DEFINITIONS *********************************/
  72. #define Led0_pin    9
  73.  
  74. /********************************** SLOT DEFINITIONS *********************************/
  75. #define LED0        0
  76.  
  77. /****************************************** SETUP ***********************************/
  78. void setup()
  79. {
  80.  
  81. /************************ENABLE IR RECEIVER*******************/
  82.         irrecv.enableIRIn(); // Start the receiver
  83.    
  84. /************************ NETWORK SET ************************/  
  85.     // Setup the network configuration
  86.     //
  87.     // The vNet address is 11(hex) that is 17(dec), so the IP address is
  88.     // the DEFAULT_BASEIPADDRESS[] defined in ethUsrCfg.h plus 17 on last
  89.     // octect. If DEFAULT_BASEIPADDRESS[] = {192, 168, 1, 0} the IP address
  90.     // for the board will be 192.168.1.17
  91.     Souliss_SetAddress(eth_bridge_address, myvNet_subnet, myvNet_supern);
  92.     SetAsGateway(eth_bridge_address);
  93.  
  94. /*********************** LED STRIPS ***********************/
  95.     Set_SimpleLight(LED0);  //Led
  96.  
  97. /********************** PIN SET **************************/        
  98.  
  99.     pinMode(Led0_pin, OUTPUT);                 
  100. }
  101.  
  102. /*********************************************** LOOP **********************************************/
  103. void loop()
  104. {  
  105.        
  106.     // Here we start to play
  107.     EXECUTEFAST() {                    
  108.         UPDATEFAST();  
  109.          
  110.         FAST_50ms() {   // We process the logic and relevant input and output every 50 milliseconds
  111.                         read_IR(); // READ IR CODES, only one call every loop is needed.              
  112. /******************************* LOGIC LED STRIPS ************************************/
  113.                         Souliss_IrIn(B4, Souliss_T1n_ToogleCmd, memory_map, LED0);
  114.                                                
  115.                         Logic_SimpleLight(LED0);                        
  116.                         ssDigOut(Led0_pin, Souliss_T1n_Coil, LED0);
  117.                        
  118.         }
  119.  
  120.         FAST_GatewayComms();
  121.                
  122.     }
  123.    
  124.     EXECUTESLOW() {
  125.         UPDATESLOW();
  126.                 SLOW_10s() {
  127. /********************************TIMER LED STRIPS*****************************/            
  128.                         Timer_SimpleLight(LED0);
  129.                 }
  130.     }      
  131. }
  132.  
  133. /******************************************** HACK FUNCTIONS *******************************************/
  134. void read_IR() {
  135.     if (irrecv.decode(&results)) {
  136.         irrecv.resume(); // Receive the next value
  137.         if (DEBUG_IR) Serial.println(results.value);//, HEX);
  138.     }
  139. }
  140.  
  141. uint8_t Souliss_IrIn(long remote_button, uint8_t value_state1, uint8_t *memory_map, uint8_t slot) {
  142.    
  143.     if (results.value == remote_button)
  144.      {
  145.                 memory_map[MaCaco_IN_s + slot] = value_state1;
  146.                 results.value = 0;
  147.         return MaCaco_DATACHANGED;
  148.      }
  149.      else return MaCaco_NODATACHANGED;
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement