discoverpixy
Macros | Enumerations | Functions | Variables
screen_pixytest.c File Reference
#include "screen_pixytest.h"
#include "button.h"
#include "numupdown.h"
#include "tft.h"
#include "touch.h"
#include "pixy.h"
#include "system.h"
#include "pixy_frame.h"
Include dependency graph for screen_pixytest.c:

Go to the source code of this file.

Macros

#define SERVO_BUTTON_Y   10
 
#define SERVO_BUTTON_SPACING   5
 
#define LED_COLOR_BUTTON_Y   35
 
#define LED_COLOR_BUTTON_SPACING   5
 
#define LED_POWER_BUTTON_Y   70
 

Enumerations

enum  {
  detecting, idle, update_servos, update_ledcolor,
  update_ledcurrent
}
 

Functions

static void b_back_cb (void *button)
 
static void b_servos_center_cb (void *button)
 
static void b_servos_topleft_cb (void *button)
 
static void b_servos_topright_cb (void *button)
 
static void b_servos_bottomleft_cb (void *button)
 
static void b_servos_bottomright_cb (void *button)
 
static void b_led_off_cb (void *button)
 
static void b_led_white_cb (void *button)
 
static void b_led_red_cb (void *button)
 
static void b_led_green_cb (void *button)
 
static void b_led_blue_cb (void *button)
 
static void n_led_powerlimit_cb (void *numupdown, int16_t value)
 
static void enter (void *screen)
 
static void leave (void *screen)
 
static void update (void *screen)
 
SCREEN_STRUCTget_screen_pixytest ()
 

Variables

static enum { ... }  state
 
static BUTTON_STRUCT b_back
 
static BUTTON_STRUCT b_servos_center
 
static BUTTON_STRUCT b_servos_topleft
 
static BUTTON_STRUCT b_servos_topright
 
static BUTTON_STRUCT b_servos_bottomleft
 
static BUTTON_STRUCT b_servos_bottomright
 
static uint16_t servo_x
 
static uint16_t servo_y
 
static BUTTON_STRUCT b_led_off
 
static BUTTON_STRUCT b_led_white
 
static BUTTON_STRUCT b_led_red
 
static BUTTON_STRUCT b_led_green
 
static BUTTON_STRUCT b_led_blue
 
static uint32_t led_color
 
static uint32_t led_maxcurrent
 
static NUMUPDOWN_STRUCT n_led_powerlimit
 
static SCREEN_STRUCT screen
 

Macro Definition Documentation

#define LED_COLOR_BUTTON_SPACING   5
#define LED_COLOR_BUTTON_Y   35
#define LED_POWER_BUTTON_Y   70
#define SERVO_BUTTON_SPACING   5
#define SERVO_BUTTON_Y   10

Enumeration Type Documentation

anonymous enum
Enumerator
detecting 
idle 
update_servos 
update_ledcolor 
update_ledcurrent 

Definition at line 30 of file screen_pixytest.c.

Function Documentation

static void b_back_cb ( void *  button)
static

Definition at line 53 of file screen_pixytest.c.

54 {
56 }
bool gui_screen_back()
Definition: screen.c:85

Here is the call graph for this function:

Here is the caller graph for this function:

static void b_led_blue_cb ( void *  button)
static

Definition at line 135 of file screen_pixytest.c.

136 {
137  if (state == idle) {
138  led_color = 0x0000FF;
140  }
141 }
static enum @1 state
static uint32_t led_color

Here is the caller graph for this function:

static void b_led_green_cb ( void *  button)
static

Definition at line 127 of file screen_pixytest.c.

128 {
129  if (state == idle) {
130  led_color = 0x00FF00;
132  }
133 }
static enum @1 state
static uint32_t led_color

Here is the caller graph for this function:

static void b_led_off_cb ( void *  button)
static

Definition at line 103 of file screen_pixytest.c.

104 {
105  if (state == idle) {
106  led_color = 0x000000;
108  }
109 }
static enum @1 state
static uint32_t led_color

Here is the caller graph for this function:

static void b_led_red_cb ( void *  button)
static

Definition at line 119 of file screen_pixytest.c.

120 {
121  if (state == idle) {
122  led_color = 0xFF0000;
124  }
125 }
static enum @1 state
static uint32_t led_color

Here is the caller graph for this function:

static void b_led_white_cb ( void *  button)
static

Definition at line 111 of file screen_pixytest.c.

112 {
113  if (state == idle) {
114  led_color = 0xFFFFFF;
116  }
117 }
static enum @1 state
static uint32_t led_color

Here is the caller graph for this function:

static void b_servos_bottomleft_cb ( void *  button)
static

Definition at line 85 of file screen_pixytest.c.

86 {
87  if (state == idle) {
88  servo_x = 0;
89  servo_y = 1000;
91  }
92 }
static uint16_t servo_x
static enum @1 state
static uint16_t servo_y

Here is the caller graph for this function:

static void b_servos_bottomright_cb ( void *  button)
static

Definition at line 94 of file screen_pixytest.c.

95 {
96  if (state == idle) {
97  servo_x = 1000;
98  servo_y = 1000;
100  }
101 }
static uint16_t servo_x
static enum @1 state
static uint16_t servo_y

Here is the caller graph for this function:

static void b_servos_center_cb ( void *  button)
static

Definition at line 58 of file screen_pixytest.c.

59 {
60  if (state == idle) {
61  servo_x = 500;
62  servo_y = 500;
64  }
65 }
static uint16_t servo_x
static enum @1 state
static uint16_t servo_y

Here is the caller graph for this function:

static void b_servos_topleft_cb ( void *  button)
static

Definition at line 67 of file screen_pixytest.c.

68 {
69  if (state == idle) {
70  servo_x = 0;
71  servo_y = 0;
73  }
74 }
static uint16_t servo_x
static enum @1 state
static uint16_t servo_y

Here is the caller graph for this function:

static void b_servos_topright_cb ( void *  button)
static

Definition at line 76 of file screen_pixytest.c.

77 {
78  if (state == idle) {
79  servo_x = 1000;
80  servo_y = 0;
82  }
83 }
static uint16_t servo_x
static enum @1 state
static uint16_t servo_y

Here is the caller graph for this function:

static void enter ( void *  screen)
static

Definition at line 151 of file screen_pixytest.c.

152 {
153  tft_clear(WHITE);
154 
155  //Back button
156  b_back.base.x1 = 10; //Start X of Button
157  b_back.base.y1 = 210; //Start Y of Button
158  b_back.base.x2 = AUTO; //Auto Calculate X2 with String Width
159  b_back.base.y2 = AUTO; //Auto Calculate Y2 with String Height
160  b_back.txtcolor = WHITE; //Set foreground color
161  b_back.bgcolor = HEX(0xAE1010); //Set background color (Don't take 255 or 0 on at least one channel, to make shadows possible)
162  b_back.font = 0; //Select Font
163  b_back.text = "Back"; //Set Text (For formatted strings take sprintf)
164  b_back.callback = b_back_cb; //Call b_back_cb as Callback
165  gui_button_add(&b_back); //Register Button (and run the callback from now on)
166 
167 
168  //Servo stuff
169 #define SERVO_BUTTON_Y 10
170 #define SERVO_BUTTON_SPACING 5
171  tft_print_line(5, SERVO_BUTTON_Y, BLACK, TRANSPARENT, 0, "Servos:");
172 
173  b_servos_center.base.x1 = 55;
178  b_servos_center.bgcolor = HEX(0xAE1010);
179  b_servos_center.font = 0;
180  b_servos_center.text = "Center";
183 
189  b_servos_topleft.bgcolor = HEX(0xAE1010);
191  b_servos_topleft.text = "ToLe";
194 
200  b_servos_topright.bgcolor = HEX(0xAE1010);
202  b_servos_topright.text = "ToRi";
205 
211  b_servos_bottomleft.bgcolor = HEX(0xAE1010);
213  b_servos_bottomleft.text = "BoLe";
216 
222  b_servos_bottomright.bgcolor = HEX(0xAE1010);
224  b_servos_bottomright.text = "BoRi";
227 
228  //Led Color stuff
229 #define LED_COLOR_BUTTON_Y 35
230 #define LED_COLOR_BUTTON_SPACING 5
231  tft_print_line(5, LED_COLOR_BUTTON_Y, BLACK, TRANSPARENT, 0, "Led Color:");
232 
233  b_led_off.base.x1 = 85;
235  b_led_off.base.x2 = AUTO;
236  b_led_off.base.y2 = AUTO;
239  b_led_off.font = 0;
240  b_led_off.text = "Off";
243 
249  b_led_white.bgcolor = HEX(0xEEEEEE);
250  b_led_white.font = 0;
251  b_led_white.text = "White";
254 
257  b_led_red.base.x2 = AUTO;
258  b_led_red.base.y2 = AUTO;
260  b_led_red.bgcolor = HEX(0xEE0000);
261  b_led_red.font = 0;
262  b_led_red.text = "Red";
265 
271  b_led_green.bgcolor = HEX(0x00EE00);
272  b_led_green.font = 0;
273  b_led_green.text = "Green";
276 
282  b_led_blue.bgcolor = HEX(0x0000EE);
283  b_led_blue.font = 0;
284  b_led_blue.text = "Blue";
287 
288  //Led MaxPower stuff
289 #define LED_POWER_BUTTON_Y 70
290  tft_print_line(5, LED_POWER_BUTTON_Y, BLACK, TRANSPARENT, 0, "Led Maximum Current:");
291 
292  //Num up down test
293  n_led_powerlimit.x = 160;
296  n_led_powerlimit.value = 10;
297  n_led_powerlimit.max = 40;
298  n_led_powerlimit.min = 0;
301 
302 
303 
304  state = detecting;
305 }
static void b_back_cb(void *button)
const char * text
The label of the button.
Definition: button.h:61
static void b_led_blue_cb(void *button)
uint16_t txtcolor
The 16-bit text color.
Definition: button.h:59
#define AUTO
Use this value instead of x2, y2 in the BUTTON_STRUCT to autocalculate the button width/height...
Definition: button.h:65
#define SERVO_BUTTON_Y
uint16_t x
The x-Coordinate of the Top-Left Starting Point.
Definition: numupdown.h:49
uint16_t y1
Top Left Y-Coordinate of Area.
Definition: touch.h:75
static BUTTON_STRUCT b_led_green
static void b_servos_bottomleft_cb(void *button)
bool gui_button_add(BUTTON_STRUCT *button)
Definition: button.c:133
void tft_print_line(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, const char *text)
Definition: tft.c:98
static void b_led_green_cb(void *button)
uint16_t x1
Top Left X-Coordinate of Area.
Definition: touch.h:74
static void b_servos_topright_cb(void *button)
#define TRANSPARENT
Definition: tft.h:66
static void b_led_white_cb(void *button)
uint16_t bgcolor
The 16-bit background color of the button.
Definition: button.h:57
TOUCH_AREA_STRUCT base
Basic geometry of the button. You only need to set the x1, y1, x2, y2 members of this struct...
Definition: button.h:56
#define LED_COLOR_BUTTON_Y
static BUTTON_STRUCT b_servos_bottomleft
NUMUPDOWN_CALLBACK callback
Callback which is executed when the value changes.
Definition: numupdown.h:55
#define HEX(h)
Definition: tft.h:60
uint16_t y2
Bottom Right Y-Coordinate of Area.
Definition: touch.h:77
static void b_led_off_cb(void *button)
uint16_t y
The y-Coordinate of the Top-Left Starting Point.
Definition: numupdown.h:50
static void b_servos_topleft_cb(void *button)
int16_t max
The maximum possible value (inclusive)
Definition: numupdown.h:54
static BUTTON_STRUCT b_led_white
void tft_clear(uint16_t color)
Definition: tft.c:45
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
static void b_led_red_cb(void *button)
int16_t min
The minimum possible value (inclusive)
Definition: numupdown.h:53
#define WHITE
Definition: tft.h:53
static BUTTON_STRUCT b_servos_topleft
static NUMUPDOWN_STRUCT n_led_powerlimit
static BUTTON_STRUCT b_back
static enum @1 state
static void b_servos_bottomright_cb(void *button)
uint16_t fgcolor
The 16-bit color of the value-text.
Definition: numupdown.h:51
static void b_servos_center_cb(void *button)
static BUTTON_STRUCT b_led_blue
#define LED_COLOR_BUTTON_SPACING
#define SERVO_BUTTON_SPACING
static BUTTON_STRUCT b_led_red
#define LED_POWER_BUTTON_Y
static void n_led_powerlimit_cb(void *numupdown, int16_t value)
static BUTTON_STRUCT b_servos_topright
int16_t value
The current/default value.
Definition: numupdown.h:52
BUTTON_CALLBACK callback
Callback which is executed when the button is pressed.
Definition: button.h:58
static BUTTON_STRUCT b_servos_center
static BUTTON_STRUCT b_servos_bottomright
uint8_t font
The number of the font to use.
Definition: button.h:60
static BUTTON_STRUCT b_led_off
#define BLACK
Definition: tft.h:54
bool gui_numupdown_add(NUMUPDOWN_STRUCT *numupdown)
Definition: numupdown.c:80

Here is the call graph for this function:

static void leave ( void *  screen)
static

Definition at line 307 of file screen_pixytest.c.

308 {
321 
322 }
static BUTTON_STRUCT b_led_green
static BUTTON_STRUCT b_servos_bottomleft
static BUTTON_STRUCT b_led_white
void gui_numupdown_remove(NUMUPDOWN_STRUCT *numupdown)
Definition: numupdown.c:136
void gui_button_remove(BUTTON_STRUCT *button)
Definition: button.c:184
static BUTTON_STRUCT b_servos_topleft
static NUMUPDOWN_STRUCT n_led_powerlimit
static BUTTON_STRUCT b_back
static BUTTON_STRUCT b_led_blue
static BUTTON_STRUCT b_led_red
static BUTTON_STRUCT b_servos_topright
static BUTTON_STRUCT b_servos_center
static BUTTON_STRUCT b_servos_bottomright
static BUTTON_STRUCT b_led_off

Here is the call graph for this function:

static void n_led_powerlimit_cb ( void *  numupdown,
int16_t  value 
)
static

Definition at line 143 of file screen_pixytest.c.

144 {
145  if (state == idle) {
146  led_maxcurrent = value;
148  }
149 }
static uint32_t led_maxcurrent
static enum @1 state

Here is the caller graph for this function:

static void update ( void *  screen)
static

Definition at line 325 of file screen_pixytest.c.

326 {
327  switch (state) {
328  case detecting: //Detecting State: Where we try to connect to the pixy
329  if (pixy_init() == 0) { //Pixy connection ok
330  int32_t response;
331  int return_value;
332  return_value = pixy_command("stop", END_OUT_ARGS, &response, END_IN_ARGS);
334 
335  state = idle; //Go to next state
336  }
337 
338  break;
339 
340  case idle:
341  pixy_service();
342  break;
343 
344  case update_servos:
347  state = idle;
348  break;
349 
350  case update_ledcolor: {
351  int32_t response;
352  int return_value;
353  return_value = pixy_command("led_set", INT32(led_color), END_OUT_ARGS, &response, END_IN_ARGS);
354  state = idle;
355  }
356  break;
357 
358  case update_ledcurrent:
360  state = idle;
361  break;
362  }
363 
364 }
#define INT32(v)
Definition: pixydefs.h:65
static uint16_t servo_x
int pixy_service()
static uint32_t led_maxcurrent
int pixy_command(const char *name,...)
Send a command to Pixy.
int pixy_led_set_max_current(uint32_t current)
Set pixy LED maximum current.
int pixy_init()
Creates a connection with Pixy and listens for Pixy messages.
#define END_OUT_ARGS
Definition: pixydefs.h:89
static enum @1 state
int pixy_rcs_set_position(uint8_t channel, uint16_t position)
Set pixy servo axis position.
static uint32_t led_color
#define END_IN_ARGS
Definition: pixydefs.h:90
static uint16_t servo_y

Here is the call graph for this function:

Variable Documentation

BUTTON_STRUCT b_back
static

Definition at line 32 of file screen_pixytest.c.

BUTTON_STRUCT b_led_blue
static

Definition at line 46 of file screen_pixytest.c.

BUTTON_STRUCT b_led_green
static

Definition at line 45 of file screen_pixytest.c.

BUTTON_STRUCT b_led_off
static

Definition at line 42 of file screen_pixytest.c.

BUTTON_STRUCT b_led_red
static

Definition at line 44 of file screen_pixytest.c.

BUTTON_STRUCT b_led_white
static

Definition at line 43 of file screen_pixytest.c.

BUTTON_STRUCT b_servos_bottomleft
static

Definition at line 37 of file screen_pixytest.c.

BUTTON_STRUCT b_servos_bottomright
static

Definition at line 38 of file screen_pixytest.c.

BUTTON_STRUCT b_servos_center
static

Definition at line 34 of file screen_pixytest.c.

BUTTON_STRUCT b_servos_topleft
static

Definition at line 35 of file screen_pixytest.c.

BUTTON_STRUCT b_servos_topright
static

Definition at line 36 of file screen_pixytest.c.

uint32_t led_color
static

Definition at line 47 of file screen_pixytest.c.

uint32_t led_maxcurrent
static

Definition at line 49 of file screen_pixytest.c.

NUMUPDOWN_STRUCT n_led_powerlimit
static

Definition at line 50 of file screen_pixytest.c.

SCREEN_STRUCT screen
static
Initial value:
= {
}
static void leave(void *screen)
static void update(void *screen)
static void enter(void *screen)

Definition at line 367 of file screen_pixytest.c.

uint16_t servo_x
static

Definition at line 39 of file screen_pixytest.c.

uint16_t servo_y
static

Definition at line 40 of file screen_pixytest.c.

enum { ... } state