/* Lights - WS2812B Leds strip */
const struct pio leds = LPC_GPIO_0_3;
+#define NB_LEDS 6
+
+uint8_t ws2812_leds_data[NB_LEDS * 3];
+struct ws2812_conf led_strip = {
+ .nb_leds = NB_LEDS,
+ .led_data = ws2812_leds_data,
+ .inverted = 0,
+};
+
+
/* External movement detector */
const struct pio ext_move_pin = LPC_GPIO_0_4;
timer_conf.match_values[2] = servo_med_pos_cmd;
timer_conf.period = servo_command_period;
- timer_on(LPC_TIMER_32B0, 0, NULL);
+ timer_on(LPC_TIMER_32B0, 0, NULL);
timer_pwm_config(LPC_TIMER_32B0, &timer_conf);
timer_start(LPC_TIMER_32B0);
- timer_on(LPC_TIMER_32B1, 0, NULL);
+ timer_on(LPC_TIMER_32B1, 0, NULL);
timer_pwm_config(LPC_TIMER_32B1, &timer_conf);
timer_start(LPC_TIMER_32B1);
add_systick_callback(ultrasound_sensors_update, 40);
timer_conf.match[0] = match;
- timer_on(LPC_TIMER_16B0, 0, ultrasound_sensors_trig_timer_int);
+ timer_on(LPC_TIMER_16B0, 0, ultrasound_sensors_trig_timer_int);
timer_counter_config(LPC_TIMER_16B0, &timer_conf);
#if (DEBUG == 1)
void send_on_rf(void)
{
- uint8_t cc_tx_data[RF_BUFF_LEN + 2];
- uint8_t tx_len = cc_ptr;
- int ret = 0;
-
- /* Create a local copy */
- memcpy((char*)&(cc_tx_data[2]), (char*)cc_tx_buff, tx_len);
- /* "Free" the rx buffer as soon as possible */
- cc_ptr = 0;
- /* Prepare buffer for sending */
- cc_tx_data[0] = tx_len + 1;
- cc_tx_data[1] = 0; /* Broadcast */
- /* Send */
- if (cc1101_tx_fifo_state() != 0) {
- cc1101_flush_tx_fifo();
- }
- ret = cc1101_send_packet(cc_tx_data, (tx_len + 2));
+ uint8_t cc_tx_data[RF_BUFF_LEN + 2];
+ uint8_t tx_len = cc_ptr;
+ int ret = 0;
+
+ /* Create a local copy */
+ memcpy((char*)&(cc_tx_data[2]), (char*)cc_tx_buff, tx_len);
+ /* "Free" the rx buffer as soon as possible */
+ cc_ptr = 0;
+ /* Prepare buffer for sending */
+ cc_tx_data[0] = tx_len + 1;
+ cc_tx_data[1] = 0; /* Broadcast */
+ /* Send */
+ if (cc1101_tx_fifo_state() != 0) {
+ cc1101_flush_tx_fifo();
+ }
+ ret = cc1101_send_packet(cc_tx_data, (tx_len + 2));
#if (DEBUG == 1)
/* Give some feedback on UART 0 */
break;
case PKT_TYPE_SET_RGB_LED:
for (i = 0; i < head->data.size; i += 4) {
- ws2812_set_pixel(data[i], data[i + 1], data[i + 2], data[i + 3]);
+ ws2812_set_pixel(&led_strip, data[i], data[i + 1], data[i + 2], data[i + 3]);
uprintf(UART_DEBUG, "Set led %d to {%d, %d, %d}.\n", data[i], data[i + 1], data[i + 2], data[i + 3]);
}
uprintf(UART_DEBUG, "Set %d leds.\n", (i / 4));
break;
case PKT_TYPE_CLEAR_LEDS:
uprintf(UART_DEBUG, "All leds cleared.\n");
- ws2812_clear();
+ ws2812_clear(&led_strip);
break;
case PKT_TYPE_SET_DIRECTION:
if (data[0] > DIRECTION_CTRL_SERVO_MAX) {
servo_config(UART_DEBUG);
/* Config Leds for lights */
- ws2812_config(&leds);
+ ws2812_config(&led_strip, &leds);
while (1) {
struct packet* pkt = NULL;
}
/* Send leds frame if leds changed */
- ws2812_send_frame(0);
+ ws2812_send_frame(&led_strip, 0);
/* RF */
if (cc_tx == 1) {
cc_tx = 0;
}
/* Do not leave radio in an unknown or unwated state */
- do {
- status = (cc1101_read_status() & CC1101_STATE_MASK);
- } while (status == CC1101_STATE_TX);
+ do {
+ status = (cc1101_read_status() & CC1101_STATE_MASK);
+ } while (status == CC1101_STATE_TX);
if (status != CC1101_STATE_RX) {
if (cc1101_rx_fifo_state() != 0) {