Andriy Makukha / Mbed 2 deprecated football_project_wo_output

Dependencies:   mbed

Fork of football_project by MZJ

Committer:
elmbed
Date:
Tue Nov 03 07:05:15 2015 +0000
Revision:
17:d8b901d791fd
Child:
30:c60b0d52b067
Removed the inter device radio link, sending data to phone causes crash

Who changed what in which revision?

UserRevisionLine numberNew contents of line
elmbed 17:d8b901d791fd 1 #ifndef TA_H
elmbed 17:d8b901d791fd 2 #define TA_H
elmbed 17:d8b901d791fd 3
elmbed 17:d8b901d791fd 4 #include <mbed.h>
elmbed 17:d8b901d791fd 5
elmbed 17:d8b901d791fd 6 #include "ByteBuffer.h"
elmbed 17:d8b901d791fd 7 #include "neopixel.h"
elmbed 17:d8b901d791fd 8
elmbed 17:d8b901d791fd 9 #define DATA_SIZE 24
elmbed 17:d8b901d791fd 10 #define SILENT 0x20
elmbed 17:d8b901d791fd 11
elmbed 17:d8b901d791fd 12 struct Message
elmbed 17:d8b901d791fd 13 {
elmbed 17:d8b901d791fd 14 char command;
elmbed 17:d8b901d791fd 15 uint32_t value;
elmbed 17:d8b901d791fd 16 uint8_t cone;
elmbed 17:d8b901d791fd 17 };
elmbed 17:d8b901d791fd 18
elmbed 17:d8b901d791fd 19 class TA
elmbed 17:d8b901d791fd 20 {
elmbed 17:d8b901d791fd 21 private:
elmbed 17:d8b901d791fd 22 // You will need to initialize the radio by telling it what ID it has and what network it's on
elmbed 17:d8b901d791fd 23 // The NodeID takes values from 1-127, 0 is reserved for sending broadcast messages (send to all nodes)
elmbed 17:d8b901d791fd 24 // The Network ID takes values from 0-255
elmbed 17:d8b901d791fd 25 // By default the SPI-SS line used is D10 on Atmega328. You can change it by calling .SetCS(pin) where pin can be {8,9,10}
elmbed 17:d8b901d791fd 26 static uint8_t node_id; // 1 //network ID used for this unit
elmbed 17:d8b901d791fd 27 static uint8_t network_id;// 99 //network ID used for this network
elmbed 17:d8b901d791fd 28 static uint8_t gateway_id;// 1 //the ID of the network controller
elmbed 17:d8b901d791fd 29 static uint8_t ack_time;// 50 // # of ms to wait for an ack
elmbed 17:d8b901d791fd 30
elmbed 17:d8b901d791fd 31 static ByteBuffer send_buffer;
elmbed 17:d8b901d791fd 32 static ByteBuffer receive_buffer;
elmbed 17:d8b901d791fd 33
elmbed 17:d8b901d791fd 34 //encryption is OPTIONAL
elmbed 17:d8b901d791fd 35 //to enable encryption you will need to:
elmbed 17:d8b901d791fd 36 // - provide a 16-byte encryption KEY (same on all nodes that talk encrypted)
elmbed 17:d8b901d791fd 37 // - to call .Encrypt(KEY) to start encrypting
elmbed 17:d8b901d791fd 38 // - to stop encrypting call .Encrypt(NULL)
elmbed 17:d8b901d791fd 39 static uint8_t KEY[];// = "ABCDABCDABCDABCD";
elmbed 17:d8b901d791fd 40 static uint16_t interPacketDelay;// = 1000; //wait this many ms between sending packets
elmbed 17:d8b901d791fd 41
elmbed 17:d8b901d791fd 42 // Need an instance of the Radio Module
elmbed 17:d8b901d791fd 43 unsigned char sendSize;//=0;
elmbed 17:d8b901d791fd 44 char payload[];// = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
elmbed 17:d8b901d791fd 45 bool requestACK;//=true;
elmbed 17:d8b901d791fd 46
elmbed 17:d8b901d791fd 47 //static neopixels_spi neopixels;
elmbed 17:d8b901d791fd 48
elmbed 17:d8b901d791fd 49 // LED controller
elmbed 17:d8b901d791fd 50 static DigitalOut SDI;
elmbed 17:d8b901d791fd 51 static DigitalOut CKI;
elmbed 17:d8b901d791fd 52
elmbed 17:d8b901d791fd 53 //static uint32_t last_rgb;
elmbed 17:d8b901d791fd 54
elmbed 17:d8b901d791fd 55 // outputs
elmbed 17:d8b901d791fd 56 //static uint8_t buzzPin;
elmbed 17:d8b901d791fd 57 //static uint8_t capPin;
elmbed 17:d8b901d791fd 58 static uint8_t red;
elmbed 17:d8b901d791fd 59 static uint8_t green;
elmbed 17:d8b901d791fd 60 static uint8_t blue;
elmbed 17:d8b901d791fd 61
elmbed 17:d8b901d791fd 62 static DigitalOut enable_1;
elmbed 17:d8b901d791fd 63 static DigitalOut enable_2;
elmbed 17:d8b901d791fd 64 static DigitalOut enable_3;
elmbed 17:d8b901d791fd 65
elmbed 17:d8b901d791fd 66 static DigitalOut cap_enable;
elmbed 17:d8b901d791fd 67 static DigitalOut buzzPin;
elmbed 17:d8b901d791fd 68
elmbed 17:d8b901d791fd 69 static DigitalIn touch_1;
elmbed 17:d8b901d791fd 70 static DigitalIn touch_2;
elmbed 17:d8b901d791fd 71 static DigitalIn touch_3;
elmbed 17:d8b901d791fd 72
elmbed 17:d8b901d791fd 73
elmbed 17:d8b901d791fd 74 // lights
elmbed 17:d8b901d791fd 75 static uint8_t mask;
elmbed 17:d8b901d791fd 76
elmbed 17:d8b901d791fd 77 // beeping
elmbed 17:d8b901d791fd 78 bool beeping;
elmbed 17:d8b901d791fd 79 unsigned long beep_start;
elmbed 17:d8b901d791fd 80 unsigned long beep_duration;
elmbed 17:d8b901d791fd 81
elmbed 17:d8b901d791fd 82 // pulsing
elmbed 17:d8b901d791fd 83 uint32_t current_color;
elmbed 17:d8b901d791fd 84 bool pulsing;
elmbed 17:d8b901d791fd 85 unsigned long pulse_start;
elmbed 17:d8b901d791fd 86 unsigned long pulse_period;
elmbed 17:d8b901d791fd 87 unsigned long pulse_on;
elmbed 17:d8b901d791fd 88 unsigned long pulse_duration;
elmbed 17:d8b901d791fd 89
elmbed 17:d8b901d791fd 90 bool powering_up1;
elmbed 17:d8b901d791fd 91 bool powering_up2;
elmbed 17:d8b901d791fd 92 unsigned long powerup_start;
elmbed 17:d8b901d791fd 93 unsigned long powerup_toggle;
elmbed 17:d8b901d791fd 94
elmbed 17:d8b901d791fd 95 // private functions
elmbed 17:d8b901d791fd 96 bool waitForAck(int cone);
elmbed 17:d8b901d791fd 97 void ledSetup(void);
elmbed 17:d8b901d791fd 98 bool _send(char *message, uint8_t cone);
elmbed 17:d8b901d791fd 99 bool _recieve(void);
elmbed 17:d8b901d791fd 100 public:
elmbed 17:d8b901d791fd 101 //constructor
elmbed 17:d8b901d791fd 102 TA();
elmbed 17:d8b901d791fd 103
elmbed 17:d8b901d791fd 104 char data[DATA_SIZE];
elmbed 17:d8b901d791fd 105 //static uint8_t networkID; // network group
elmbed 17:d8b901d791fd 106
elmbed 17:d8b901d791fd 107 void post_color(uint32_t rgb);
elmbed 17:d8b901d791fd 108 void mask_color(uint32_t rgb);
elmbed 17:d8b901d791fd 109 void beep(uint16_t ms);
elmbed 17:d8b901d791fd 110 void beep_off(void);
elmbed 17:d8b901d791fd 111 void powerup(uint8_t);
elmbed 17:d8b901d791fd 112 void pulse(uint16_t on_time, uint16_t period, uint16_t ms, uint32_t rgb);
elmbed 17:d8b901d791fd 113 void pulse_off(void);
elmbed 17:d8b901d791fd 114 int get_buffer_size(void);
elmbed 17:d8b901d791fd 115 bool send(Message *m);
elmbed 17:d8b901d791fd 116 void send_immediate(Message *m);
elmbed 17:d8b901d791fd 117 bool sendRaw(uint8_t *message, uint8_t len, uint8_t cone);
elmbed 17:d8b901d791fd 118 bool recieve(Message *m);
elmbed 17:d8b901d791fd 119 void spin(void);
elmbed 17:d8b901d791fd 120 bool activated(void);
elmbed 17:d8b901d791fd 121 bool tripped(void);
elmbed 17:d8b901d791fd 122 uint8_t buttons(void);
elmbed 17:d8b901d791fd 123 void setMask(uint8_t the_mask);
elmbed 17:d8b901d791fd 124 void initialize(uint8_t address);
elmbed 17:d8b901d791fd 125
elmbed 17:d8b901d791fd 126 void Ram_TableDisplay(void);
elmbed 17:d8b901d791fd 127 void get_free_memory(void);
elmbed 17:d8b901d791fd 128 void check_mem(void);
elmbed 17:d8b901d791fd 129
elmbed 17:d8b901d791fd 130 };
elmbed 17:d8b901d791fd 131
elmbed 17:d8b901d791fd 132
elmbed 17:d8b901d791fd 133 #endif