From 42b6e3af369fffb07dc4f586a8ad9eb129b9a73c Mon Sep 17 00:00:00 2001 From: Timo Lang Date: Mon, 8 Jun 2015 11:04:50 +0200 Subject: [PATCH] Updated docu. --- annotated.html | 2 +- app_8c.html | 6 +- app_8c_source.html | 169 +++++ app_8h.html | 2 +- app_8h_source.html | 42 +- button_8c.html | 119 +++- button_8c_source.html | 324 +++++++++ button_8h.html | 2 +- button_8h_source.html | 108 +-- checkbox_8c.html | 65 +- checkbox_8c_source.html | 277 ++++++++ checkbox_8h.html | 2 +- checkbox_8h_source.html | 96 +-- classes.html | 2 +- dir_000001_000002.html | 2 +- dir_000001_000003.html | 2 +- dir_000001_000005.html | 2 +- dir_000001_000006.html | 2 +- dir_000001_000007.html | 2 +- dir_000001_000008.html | 2 +- dir_000002_000004.html | 2 +- dir_000003_000007.html | 2 +- dir_000003_000008.html | 2 +- dir_000004_000002.html | 2 +- dir_000006_000004.html | 2 +- dir_000007_000002.html | 2 +- dir_000007_000004.html | 2 +- dir_000008_000003.html | 2 +- dir_000008_000004.html | 2 +- dir_000008_000007.html | 2 +- dir_0a50ab14f1d261d61cd33403a26c32cc.html | 4 +- dir_284aa68f6d81a4e6cef9d8d6fca4af3e.html | 4 +- dir_4298a0eb495ff7ff4bd3a3a3e6ccf3f0.html | 2 +- dir_5668dfef4710d48cd9d7316a574bf987.html | 6 +- dir_73c9649cd1892d880e57f5a32368877e.html | 2 +- dir_99a8943037ff3844556e6a5d529fec0c.html | 22 +- dir_ad7e3681fbb6f77d8ce503c4a3117735.html | 10 +- dir_bdd9a5d540de89e9fe90efdfc6973a4f.html | 2 +- dir_e222ac1ff707f15b04869ea0388b9123.html | 4 +- dynsections.js | 7 + files.html | 40 +- filesystem_8c.html | 6 +- filesystem_8c_source.html | 177 +++++ filesystem_8h.html | 12 +- filesystem_8h_source.html | 234 ++++--- functions.html | 2 +- functions_vars.html | 2 +- globals.html | 2 +- globals_b.html | 2 +- globals_c.html | 2 +- globals_d.html | 2 +- globals_defs.html | 2 +- globals_e.html | 2 +- globals_enum.html | 2 +- globals_eval.html | 2 +- globals_f.html | 2 +- globals_func.html | 2 +- globals_func_b.html | 2 +- globals_func_c.html | 2 +- globals_func_e.html | 2 +- globals_func_f.html | 2 +- globals_func_g.html | 2 +- globals_func_i.html | 2 +- globals_func_l.html | 2 +- globals_func_n.html | 2 +- globals_func_p.html | 2 +- globals_func_r.html | 2 +- globals_func_s.html | 2 +- globals_func_t.html | 2 +- globals_func_u.html | 2 +- globals_g.html | 2 +- globals_h.html | 2 +- globals_i.html | 2 +- globals_l.html | 2 +- globals_n.html | 2 +- globals_o.html | 2 +- globals_p.html | 2 +- globals_r.html | 2 +- globals_s.html | 2 +- globals_t.html | 2 +- globals_type.html | 2 +- globals_u.html | 2 +- globals_vars.html | 2 +- globals_w.html | 2 +- globals_x.html | 2 +- globals_y.html | 2 +- graph_legend.html | 2 +- group__app.html | 27 +- group__button.html | 97 ++- group__calibrate.html | 8 +- group__checkbox.html | 115 +++- group__filesystem.html | 90 ++- group__filetest.html | 8 +- group__gui.html | 2 +- group__guitest.html | 8 +- group__ll__filesystem.html | 2 +- group__ll__system.html | 2 +- group__ll__tft.html | 2 +- group__ll__touch.html | 2 +- group__lowlevel.html | 2 +- group__main.html | 8 +- group__numupdown.html | 149 +++- group__photomode.html | 8 +- group__photomodesave.html | 8 +- group__pixy.html | 22 +- group__pixy__control.html | 58 +- group__pixy__helper.html | 127 +++- group__pixytest.html | 8 +- group__screen.html | 96 ++- group__screens.html | 2 +- group__system.html | 26 +- group__tft.html | 200 +++++- group__touch.html | 241 ++++++- group__tracking.html | 39 +- index.html | 2 +- ll__filesystem_8h.html | 2 +- ll__filesystem_8h_source.html | 52 +- ll__system_8h.html | 2 +- ll__system_8h_source.html | 42 +- ll__tft_8h.html | 2 +- ll__tft_8h_source.html | 73 +- ll__touch_8h.html | 2 +- ll__touch_8h_source.html | 30 +- modules.html | 2 +- numupdown_8c.html | 62 +- numupdown_8c_source.html | 311 +++++++++ numupdown_8h.html | 2 +- numupdown_8h_source.html | 113 +-- pixy_8h.html | 2 +- pixy_8h_source.html | 18 +- pixy__control_8c.html | 14 +- pixy__control_8c_source.html | 194 ++++++ pixy__control_8h.html | 2 +- pixy__control_8h_source.html | 47 +- pixy__frame_8c.html | 134 +++- pixy__frame_8c_source.html | 373 ++++++++++ pixy__frame_8h.html | 2 +- pixy__frame_8h_source.html | 67 +- pixydefs_8h.html | 104 ++- pixydefs_8h_source.html | 2 +- screen_8c.html | 12 +- screen_8c_source.html | 224 ++++++ screen_8h.html | 2 +- screen_8h_source.html | 98 +-- screen__calibrate_8c.html | 122 +++- screen__calibrate_8c_source.html | 248 +++++++ screen__calibrate_8h.html | 14 +- screen__calibrate_8h_source.html | 50 +- screen__filetest_8c.html | 195 +++++- screen__filetest_8c_source.html | 326 +++++++++ screen__filetest_8h.html | 2 +- screen__filetest_8h_source.html | 35 +- screen__guitest_8c.html | 214 +++++- screen__guitest_8c_source.html | 340 +++++++++ screen__guitest_8h.html | 2 +- screen__guitest_8h_source.html | 35 +- screen__main_8c.html | 236 ++++++- screen__main_8c_source.html | 363 ++++++++++ screen__main_8h.html | 2 +- screen__main_8h_source.html | 41 +- screen__photomode_8c.html | 257 ++++++- screen__photomode_8c_source.html | 375 ++++++++++ screen__photomode_8h.html | 2 +- screen__photomode_8h_source.html | 27 +- screen__photomode__save_8c.html | 425 +++++++++++- screen__photomode__save_8c_source.html | 540 +++++++++++++++ screen__photomode__save_8h.html | 2 +- screen__photomode__save_8h_source.html | 28 +- screen__pixytest_8c.html | 506 +++++++++++++- screen__pixytest_8c_source.html | 569 +++++++++++++++ screen__pixytest_8h.html | 2 +- screen__pixytest_8h_source.html | 33 +- screen__tracking_8c.html | 532 +++++++++++++- screen__tracking_8c_source.html | 648 ++++++++++++++++++ screen__tracking_8h.html | 2 +- screen__tracking_8h_source.html | 51 +- struct_b_u_t_t_o_n___s_t_r_u_c_t.html | 16 +- struct_block.html | 21 +- struct_c_h_e_c_k_b_o_x___s_t_r_u_c_t.html | 12 +- struct_d_i_r_e_c_t_o_r_y___s_t_r_u_c_t.html | 10 +- struct_f_i_l_e___d_a_t_e___s_t_r_u_c_t.html | 10 +- struct_f_i_l_e___h_a_n_d_l_e.html | 10 +- struct_f_i_l_e___l_i_s_t___e_n_t_r_y___s.html | 13 +- struct_f_i_l_e___s_t_r_u_c_t.html | 14 +- struct_f_i_l_e___t_i_m_e___s_t_r_u_c_t.html | 10 +- struct_n_u_m_u_p_d_o_w_n___s_t_r_u_c_t.html | 22 +- struct_p_o_i_n_t___s_t_r_u_c_t.html | 8 +- struct_s_c_r_e_e_n___s.html | 12 +- struct_t_o_u_c_h___a_r_e_a___s_t_r_u_c_t.html | 18 +- ...c_k_i_n_g___c_o_n_f_i_g___s_t_r_u_c_t.html | 15 +- system_8c.html | 6 +- system_8c_source.html | 149 ++++ system_8h.html | 2 +- system_8h_source.html | 60 +- tft_8c.html | 6 +- tft_8c_source.html | 319 +++++++++ tft_8h.html | 2 +- tft_8h_source.html | 149 ++-- touch_8c.html | 50 +- touch_8c_source.html | 354 ++++++++++ touch_8h.html | 14 +- touch_8h_source.html | 190 ++--- 202 files changed, 11953 insertions(+), 976 deletions(-) create mode 100644 app_8c_source.html create mode 100644 button_8c_source.html create mode 100644 checkbox_8c_source.html create mode 100644 filesystem_8c_source.html create mode 100644 numupdown_8c_source.html create mode 100644 pixy__control_8c_source.html create mode 100644 pixy__frame_8c_source.html create mode 100644 screen_8c_source.html create mode 100644 screen__calibrate_8c_source.html create mode 100644 screen__filetest_8c_source.html create mode 100644 screen__guitest_8c_source.html create mode 100644 screen__main_8c_source.html create mode 100644 screen__photomode_8c_source.html create mode 100644 screen__photomode__save_8c_source.html create mode 100644 screen__pixytest_8c_source.html create mode 100644 screen__tracking_8c_source.html create mode 100644 system_8c_source.html create mode 100644 tft_8c_source.html create mode 100644 touch_8c_source.html diff --git a/annotated.html b/annotated.html index c365d43..aa03621 100644 --- a/annotated.html +++ b/annotated.html @@ -107,7 +107,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/app_8c.html b/app_8c.html index 23d43ba..fd5441d 100644 --- a/app_8c.html +++ b/app_8c.html @@ -104,7 +104,9 @@ Include dependency graph for app.c: - + +

Go to the source code of this file.

+
@@ -115,7 +117,7 @@ Functions diff --git a/app_8c_source.html b/app_8c_source.html new file mode 100644 index 0000000..8a65610 --- /dev/null +++ b/app_8c_source.html @@ -0,0 +1,169 @@ + + + + + + +discoverpixy: common/app/app.c Source File + + + + + + + + + + +
+
+

Functions

void app_init ()
+ + + + + +
+
discoverpixy +
+
+ + + + + + + +
+
+ + +
+ +
+ + + +
+
+
app.c
+
+
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/app/app.c
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-04-03 timolang@gmail.com 51089aa Refactored Project Structure for use with emulator
+
11 * 2015-04-03 timolang@gmail.com 1f2af9f Added more tft functions to common and emulator. Fixed eventloop.
+
12 * 2015-04-03 timolang@gmail.com cab8609 Integrated pixy into emulator. Pixy is no longer in the common/libs folder but in emulator/libs and discovery/libs
+
13 * 2015-04-03 timolang@gmail.com 1aa9194 Fixed Drawing of rects in Emulator. Got frames from pixy to emulator. Slooooow.
+
14 * 2015-04-25 timolang@gmail.com 416883c Pixy&Usb work with the new folder structure now.
+
15 * 2015-04-25 timolang@gmail.com 3d1e4b2 Simplified code a bit. Emulator does not work stable when replugging pixy.
+
16 * 2015-04-25 timolang@gmail.com 0858b0d Fixed some bugs when receiving large data.
+
17 * 2015-04-27 timolang@gmail.com 259d446 Added touch support to emulator. Implemented basic touch function.
+
18 * 2015-04-27 aaron@duckpond.ch aed90ef Drawcircle added (emulator)
+
19 * 2015-04-27 timolang@gmail.com e249fb2 Added font support
+
20 * 2015-04-27 timolang@gmail.com 7c9eabc Added button support.
+
21 * 2015-04-27 timolang@gmail.com b300ac5 Added Checkbox support
+
22 * 2015-04-27 timolang@gmail.com cf72baa Introduced a Screen (sub) module and divided app into multiple screens.
+
23 * 2015-05-10 timolang@gmail.com e2bce8f Added filesystem module, tests and implementation for it in emulator.
+
24 * 2015-05-12 aaron@duckpond.ch aec62d4 Added datasheets, updated touchsupport.
+
25 * 2015-05-28 aaron@duckpond.ch 5bda699 implemented functions to get x and y coordinates and a test function
+
26 * 2015-05-29 aaron@duckpond.ch 7d2d1a1 Implemented basic sampling and averaging of touch coordinates using timer7
+
27 *
+
28 **************************************************************************************************************************************/
+
29 
+
30 #include "app.h"
+
31 #include "tft.h"
+
32 #include "system.h"
+
33 #include "touch.h"
+
34 #include "screen_main.h"
+
35 #include "filesystem.h"
+
36 
+
37 void app_init()
+
38 {
+
39  system_init();
+
40  tft_init();
+
41  touch_init();
+ +
43 
+ +
45 }
+
46 
+
47 //app event loop
+ +
49 {
+
50 
+
51  system_process(); //Let the system handle it's pending events
+
52  gui_screen_update(); //update the currently active screen
+
53 }
+
void gui_screen_update()
Definition: screen.c:41
+ +
SCREEN_STRUCT * get_screen_main()
Definition: screen_main.c:196
+ + +
bool gui_screen_navigate(SCREEN_STRUCT *screen)
Definition: screen.c:74
+
bool system_init()
Definition: system.c:21
+
void app_process()
Definition: app.c:48
+ +
void system_process()
Definition: system.c:31
+
bool filesystem_init()
Definition: filesystem.c:18
+
bool tft_init()
Definition: tft.c:39
+ +
bool touch_init()
Definition: touch.c:61
+
void app_init()
Definition: app.c:37
+ +
+ + + + diff --git a/app_8h.html b/app_8h.html index bb5908c..fcff547 100644 --- a/app_8h.html +++ b/app_8h.html @@ -111,7 +111,7 @@ Functions diff --git a/app_8h_source.html b/app_8h_source.html index e26e593..b1f1abf 100644 --- a/app_8h_source.html +++ b/app_8h_source.html @@ -89,22 +89,38 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
app.h
-Go to the documentation of this file.
1 #ifndef APP_H
-
2 #define APP_H
-
3 
-
15 
-
20 void app_init();
-
21 
-
26 void app_process();
-
27 
-
28 
-
31 #endif /* APP_H */
-
void app_process()
Definition: app.c:18
-
void app_init()
Definition: app.c:8
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/app/app.h
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-04-03 timolang@gmail.com 51089aa Refactored Project Structure for use with emulator
+
11 * 2015-05-10 timolang@gmail.com 21edc56 Added doxyfile (doxygen) for the common folder. Started with doxygen comments for app and tft module.
+
12 * 2015-05-11 timolang@gmail.com 08d9fe0 More work on doxygen module structure
+
13 * 2015-06-08 timolang@gmail.com 73db8b5 Added doxygen mainpage comment in app.h
+
14 *
+
15 **************************************************************************************************************************************/
+
16 
+
17 #ifndef APP_H
+
18 #define APP_H
+
19 
+
31 
+
36 void app_init();
+
37 
+
42 void app_process();
+
43 
+
44 
+
47 #endif /* APP_H */
+
void app_process()
Definition: app.c:48
+
void app_init()
Definition: app.c:37
diff --git a/button_8c.html b/button_8c.html index a42e216..06f7c1f 100644 --- a/button_8c.html +++ b/button_8c.html @@ -103,7 +103,9 @@ Include dependency graph for button.c:
- + +

Go to the source code of this file.

+
@@ -160,6 +162,61 @@ Functions

Macros

#define BRIGHTNESS_VAL   3
+

Definition at line 92 of file button.c.

+
93 {
+
94  TOUCH_AREA_STRUCT* area = (TOUCH_AREA_STRUCT*)touchArea;
+
95  BUTTON_STRUCT* button = (BUTTON_STRUCT*)touchArea;
+
96 
+
97  uint16_t c_light, c_dark; //c_light and c_dark will be filled with a lighter and a darker color as the background color (for the shadows)
+
98  calculate_shadows(button->bgcolor, &c_light, &c_dark);
+
99 
+
100  switch (triggeredAction) {
+
101  case PEN_DOWN: //If the user touches the area for the "first time"
+
102  area->hookedActions = PEN_UP | PEN_LEAVE; //for the future we only want PEN_UP and PEN_LEAVE events
+
103 
+
104  //Draw shadows
+
105  tft_draw_line(button->base.x1 + 1, button->base.y1, button->base.x2 - 1, button->base.y1, c_dark); //North
+
106  tft_draw_line(button->base.x1, button->base.y1 + 1, button->base.x1, button->base.y2 - 1, c_dark); //West
+
107  tft_draw_line(button->base.x1 + 1, button->base.y2, button->base.x2 - 1, button->base.y2, c_light); //South
+
108  tft_draw_line(button->base.x2, button->base.y1 + 1, button->base.x2, button->base.y2 - 1, c_light); //East
+
109  break;
+
110 
+
111  case PEN_UP: //If the user took the pen away, while in the area (=button pressed!)
+
112  case PEN_LEAVE: //or the user "slided out" of the area
+
113  area->hookedActions = PEN_DOWN; //for the future we only want PEN_DOWN events
+
114 
+
115  //Draw inverse shadows
+
116  tft_draw_line(button->base.x1 + 1, button->base.y1, button->base.x2 - 1, button->base.y1, c_light); //North
+
117  tft_draw_line(button->base.x1, button->base.y1 + 1, button->base.x1, button->base.y2 - 1, c_light); //West
+
118  tft_draw_line(button->base.x1 + 1, button->base.y2, button->base.x2 - 1, button->base.y2, c_dark); //South
+
119  tft_draw_line(button->base.x2, button->base.y1 + 1, button->base.x2, button->base.y2 - 1, c_dark); //East
+
120 
+
121  if (triggeredAction == PEN_UP && button->callback != NULL) { //If the button got "pressed" instead of left, and the user provided a callback
+
122  button->callback(button); //execute the user callback
+
123  }
+
124 
+
125  break;
+
126 
+
127  default:
+
128  break;
+
129  }
+
130 }
+
Receive an event when the pen goes down inside the region.
Definition: touch.h:54
+
Receive an event when the pen goes up inside the region.
Definition: touch.h:55
+
void tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:50
+
uint16_t y1
Top Left Y-Coordinate of Area.
Definition: touch.h:75
+ +
uint16_t x1
Top Left X-Coordinate of Area.
Definition: touch.h:74
+
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
+ +
uint16_t y2
Bottom Right Y-Coordinate of Area.
Definition: touch.h:77
+
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
+
void calculate_shadows(uint16_t bgcolor, uint16_t *light_shadow, uint16_t *dark_shadow)
Definition: button.c:34
+
TOUCH_ACTION hookedActions
Actions to listen to.
Definition: touch.h:73
+
BUTTON_CALLBACK callback
Callback which is executed when the button is pressed.
Definition: button.h:58
+
Receive an event when the pen leaves the region (pen was inside region before)
Definition: touch.h:57
+

Here is the call graph for this function:
@@ -210,6 +267,64 @@ Here is the caller graph for this function:
+

Definition at line 34 of file button.c.

+
35 {
+
36 #define BRIGHTNESS_VAL 3 //How much the Brightness is in/decreased for button shadows (3 -> Add/Subtract 1/3 off Full Value)
+
37 
+
38  uint16_t c_light, c_dark; //c_light and c_dark will be filled with a lighter and a darker color as the background color (for the shadows)
+
39  uint8_t r, g, b;
+
40 
+
41  //separate the channels of the 16-bit rgb565 color
+
42  r = (bgcolor & 0xF800) >> 11;
+
43  g = (bgcolor & 0x07E0) >> 5;
+
44  b = (bgcolor & 0x001F) >> 0;
+
45 
+
46  //For the light shadow color:
+
47  if ((r + 0x1F / BRIGHTNESS_VAL) > 0x1F) { //Adding one third would exceed the maximum of the red channel
+
48  c_light = 0xF800; //Use full red
+
49  } else { //adding one third to the red channel is fine
+
50  c_light = (r + 0x1F / BRIGHTNESS_VAL) << 11; //Use same red as in the background, but add one third
+
51  }
+
52 
+
53  if ((g + 0x3F / BRIGHTNESS_VAL) > 0x3F) { //same for the green channel
+
54  c_light |= 0x07E0;
+
55  } else {
+
56  c_light |= (g + 0x3F / BRIGHTNESS_VAL) << 5;
+
57  }
+
58 
+
59  if ((b + 0x1F / BRIGHTNESS_VAL) > 0x1F) { //and the blue channel
+
60  c_light |= 0x0018;
+
61  } else {
+
62  c_light |= (b + 0x1F / BRIGHTNESS_VAL) << 0;
+
63  }
+
64 
+
65  //For the dark shadow color
+
66  if (r > (0x1F / BRIGHTNESS_VAL)) { //Subtracting one third would NOT exceed the minimum of the red channel
+
67  c_dark = (r - 0x1F / BRIGHTNESS_VAL) << 11; //Use same red as in the background, but subtract one third
+
68  } else { //Subtracting one third would give us a number below zero
+
69  c_dark = 0x0000; //use no red channel
+
70  }
+
71 
+
72  if (g > (0x3F / BRIGHTNESS_VAL)) { //Same for the green channel
+
73  c_dark |= (g - 0x3F / BRIGHTNESS_VAL) << 5;
+
74  }
+
75 
+
76  if (b > (0x1F / BRIGHTNESS_VAL)) { //and the blue channel
+
77  c_dark |= (b - 0x1F / BRIGHTNESS_VAL) << 0;
+
78  }
+
79 
+
80  //Assign the calculated shadows to out parameters
+
81  if (light_shadow != NULL) {
+
82  *light_shadow = c_light;
+
83  }
+
84 
+
85  if (dark_shadow != NULL) {
+
86  *dark_shadow = c_dark;
+
87  }
+
88 
+
89 }
+
#define BRIGHTNESS_VAL
+

Here is the caller graph for this function:
@@ -224,7 +339,7 @@ Here is the caller graph for this function:
diff --git a/button_8c_source.html b/button_8c_source.html new file mode 100644 index 0000000..8087c5a --- /dev/null +++ b/button_8c_source.html @@ -0,0 +1,324 @@ + + + + + + +discoverpixy: common/gui/button.c Source File + + + + + + + + + + +
+
+ + + + + + +
+
discoverpixy +
+
+
+ + + + + + +
+
+ + +
+ +
+ + +
+
+
+
button.c
+
+
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/gui/button.c
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-04-27 timolang@gmail.com 7c9eabc Added button support.
+
11 * 2015-05-17 timolang@gmail.com 2d46336 Improved comments in implementation of button, checkbox, numupdown, tft, touch and screen modules/submodules.
+
12 *
+
13 **************************************************************************************************************************************/
+
14 
+
15 #include "tft.h"
+
16 #include "touch.h"
+
17 #include "button.h"
+
18 #include <string.h>
+
19 
+
20 /* The Idea is as follows:
+
21  * When the user add's a button we create a touch area for that region and wait for PEN_DOWN events.
+
22  * Once the user puts the pen down in this area we'll redraw the button with different shadows (feedback)
+
23  * and we'll now wait on PEN_UP or PEN_LEAVE events.
+
24  * If the user takes the pen away while in the area (PEN_UP), we call the provided user callback
+
25  * Otherwise (PEN_LEAVE) we only restore the initial shadows
+
26  */
+
27 
+
28 /* Possible improvements:
+
29  * Move the button by 1 pixel while he is pressed, to create a "full 3d" experience
+
30  * Add events for the case when the button is pressed for a long time, without release
+
31  */
+
32 
+
33 //Method to calculate the shadow colors used to create the "3d" effect
+
34 void calculate_shadows(uint16_t bgcolor, uint16_t* light_shadow, uint16_t* dark_shadow)
+
35 {
+
36 #define BRIGHTNESS_VAL 3 //How much the Brightness is in/decreased for button shadows (3 -> Add/Subtract 1/3 off Full Value)
+
37 
+
38  uint16_t c_light, c_dark; //c_light and c_dark will be filled with a lighter and a darker color as the background color (for the shadows)
+
39  uint8_t r, g, b;
+
40 
+
41  //separate the channels of the 16-bit rgb565 color
+
42  r = (bgcolor & 0xF800) >> 11;
+
43  g = (bgcolor & 0x07E0) >> 5;
+
44  b = (bgcolor & 0x001F) >> 0;
+
45 
+
46  //For the light shadow color:
+
47  if ((r + 0x1F / BRIGHTNESS_VAL) > 0x1F) { //Adding one third would exceed the maximum of the red channel
+
48  c_light = 0xF800; //Use full red
+
49  } else { //adding one third to the red channel is fine
+
50  c_light = (r + 0x1F / BRIGHTNESS_VAL) << 11; //Use same red as in the background, but add one third
+
51  }
+
52 
+
53  if ((g + 0x3F / BRIGHTNESS_VAL) > 0x3F) { //same for the green channel
+
54  c_light |= 0x07E0;
+
55  } else {
+
56  c_light |= (g + 0x3F / BRIGHTNESS_VAL) << 5;
+
57  }
+
58 
+
59  if ((b + 0x1F / BRIGHTNESS_VAL) > 0x1F) { //and the blue channel
+
60  c_light |= 0x0018;
+
61  } else {
+
62  c_light |= (b + 0x1F / BRIGHTNESS_VAL) << 0;
+
63  }
+
64 
+
65  //For the dark shadow color
+
66  if (r > (0x1F / BRIGHTNESS_VAL)) { //Subtracting one third would NOT exceed the minimum of the red channel
+
67  c_dark = (r - 0x1F / BRIGHTNESS_VAL) << 11; //Use same red as in the background, but subtract one third
+
68  } else { //Subtracting one third would give us a number below zero
+
69  c_dark = 0x0000; //use no red channel
+
70  }
+
71 
+
72  if (g > (0x3F / BRIGHTNESS_VAL)) { //Same for the green channel
+
73  c_dark |= (g - 0x3F / BRIGHTNESS_VAL) << 5;
+
74  }
+
75 
+
76  if (b > (0x1F / BRIGHTNESS_VAL)) { //and the blue channel
+
77  c_dark |= (b - 0x1F / BRIGHTNESS_VAL) << 0;
+
78  }
+
79 
+
80  //Assign the calculated shadows to out parameters
+
81  if (light_shadow != NULL) {
+
82  *light_shadow = c_light;
+
83  }
+
84 
+
85  if (dark_shadow != NULL) {
+
86  *dark_shadow = c_dark;
+
87  }
+
88 
+
89 }
+
90 
+
91 //Callback which is called when the user touches the touch-area we created for the button
+
92 void buttons_cb(void* touchArea, TOUCH_ACTION triggeredAction)
+
93 {
+
94  TOUCH_AREA_STRUCT* area = (TOUCH_AREA_STRUCT*)touchArea;
+
95  BUTTON_STRUCT* button = (BUTTON_STRUCT*)touchArea;
+
96 
+
97  uint16_t c_light, c_dark; //c_light and c_dark will be filled with a lighter and a darker color as the background color (for the shadows)
+
98  calculate_shadows(button->bgcolor, &c_light, &c_dark);
+
99 
+
100  switch (triggeredAction) {
+
101  case PEN_DOWN: //If the user touches the area for the "first time"
+
102  area->hookedActions = PEN_UP | PEN_LEAVE; //for the future we only want PEN_UP and PEN_LEAVE events
+
103 
+
104  //Draw shadows
+
105  tft_draw_line(button->base.x1 + 1, button->base.y1, button->base.x2 - 1, button->base.y1, c_dark); //North
+
106  tft_draw_line(button->base.x1, button->base.y1 + 1, button->base.x1, button->base.y2 - 1, c_dark); //West
+
107  tft_draw_line(button->base.x1 + 1, button->base.y2, button->base.x2 - 1, button->base.y2, c_light); //South
+
108  tft_draw_line(button->base.x2, button->base.y1 + 1, button->base.x2, button->base.y2 - 1, c_light); //East
+
109  break;
+
110 
+
111  case PEN_UP: //If the user took the pen away, while in the area (=button pressed!)
+
112  case PEN_LEAVE: //or the user "slided out" of the area
+
113  area->hookedActions = PEN_DOWN; //for the future we only want PEN_DOWN events
+
114 
+
115  //Draw inverse shadows
+
116  tft_draw_line(button->base.x1 + 1, button->base.y1, button->base.x2 - 1, button->base.y1, c_light); //North
+
117  tft_draw_line(button->base.x1, button->base.y1 + 1, button->base.x1, button->base.y2 - 1, c_light); //West
+
118  tft_draw_line(button->base.x1 + 1, button->base.y2, button->base.x2 - 1, button->base.y2, c_dark); //South
+
119  tft_draw_line(button->base.x2, button->base.y1 + 1, button->base.x2, button->base.y2 - 1, c_dark); //East
+
120 
+
121  if (triggeredAction == PEN_UP && button->callback != NULL) { //If the button got "pressed" instead of left, and the user provided a callback
+
122  button->callback(button); //execute the user callback
+
123  }
+
124 
+
125  break;
+
126 
+
127  default:
+
128  break;
+
129  }
+
130 }
+
131 
+
132 
+ +
134 {
+
135  if (touch_have_empty(1)) { //Check if the touch module can handle one additional area
+
136  //Calculate width and height of the button text
+
137  unsigned int strwidth = tft_font_width(button->font) * strlen(button->text);
+
138  unsigned char strheight = tft_font_height(button->font);
+
139 
+
140  button->base.hookedActions = PEN_DOWN; //At first we are interested in PEN_DOWN events
+
141  button->base.callback = buttons_cb; //Use our own callback for the touch area events
+
142 
+
143  if (button->base.x2 == AUTO) { //The user wants us to calculate the button width automatically
+
144  //Use string width + half of a character width as button width
+
145  button->base.x2 = button->base.x1 - 1 + strwidth + (tft_font_width(button->font) / 2);
+
146  } else if ((button->base.x2 - button->base.x1 + 1) < (strwidth + 2)) { //the provided width is too small to fit the entire text
+
147  return false; //report error
+
148  }
+
149 
+
150  if (button->base.y2 == AUTO) { //The user wants us to calculate the button height automatically
+
151  //Use one and a half character heights as button height
+
152  button->base.y2 = button->base.y1 - 1 + strheight + (strheight / 2);
+
153  } else if ((button->base.y2 - button->base.y1 + 1) < (strheight + 2)) { //the provided height is too small to fit the text
+
154  return false;
+
155  }
+
156 
+
157  gui_button_redraw(button); //call the redraw method, which will take care of drawing the entire button
+
158  return touch_register_area(&button->base); //Register the touch area and receive events for this button, from now on
+
159  }
+
160 
+
161  return false; //no more touch areas left
+
162 }
+
163 
+ +
165 {
+
166  //Calculate text dimensions and shadow colors
+
167  unsigned int strwidth = tft_font_width(button->font) * strlen(button->text);
+
168  unsigned char strheight = tft_font_height(button->font);
+
169  uint16_t c_light, c_dark;
+
170  calculate_shadows(button->bgcolor, &c_light, &c_dark);
+
171 
+
172  //Draw the background and the 4 lines (shadow colors)
+
173  tft_fill_rectangle(button->base.x1 + 1, button->base.y1 + 1, button->base.x2 - 1, button->base.y2 - 1, button->bgcolor);
+
174  tft_draw_line(button->base.x1 + 1, button->base.y1, button->base.x2 - 1, button->base.y1, c_light); //North
+
175  tft_draw_line(button->base.x1, button->base.y1 + 1, button->base.x1, button->base.y2 - 1, c_light); //West
+
176  tft_draw_line(button->base.x1 + 1, button->base.y2, button->base.x2 - 1, button->base.y2, c_dark); //South
+
177  tft_draw_line(button->base.x2, button->base.y1 + 1, button->base.x2, button->base.y2 - 1, c_dark); //East
+
178 
+
179  //Draw the text
+
180  tft_print_line(button->base.x1 + (button->base.x2 - button->base.x1 + 1 - strwidth) / 2, button->base.y1 + (button->base.y2 - button->base.y1 + 1 - strheight) / 2, button->txtcolor, button->bgcolor, button->font, button->text);
+
181 
+
182 }
+
183 
+ +
185 {
+
186  //We only need to unregister the touch area, as we have not allocated anything else
+ +
188 }
+
TOUCH_ACTION
Definition: touch.h:52
+
uint8_t tft_font_height(uint8_t fontnum)
Definition: tft.c:87
+
bool touch_register_area(TOUCH_AREA_STRUCT *area)
Definition: touch.c:181
+
const char * text
The label of the button.
Definition: button.h:61
+
uint8_t tft_font_width(uint8_t fontnum)
Definition: tft.c:92
+
void gui_button_redraw(BUTTON_STRUCT *button)
Definition: button.c:164
+
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
+
Receive an event when the pen goes down inside the region.
Definition: touch.h:54
+
Receive an event when the pen goes up inside the region.
Definition: touch.h:55
+
void tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:50
+
uint16_t y1
Top Left Y-Coordinate of Area.
Definition: touch.h:75
+ +
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
+
uint16_t x1
Top Left X-Coordinate of Area.
Definition: touch.h:74
+
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
+
void touch_unregister_area(TOUCH_AREA_STRUCT *area)
Definition: touch.c:195
+ +
uint16_t y2
Bottom Right Y-Coordinate of Area.
Definition: touch.h:77
+
void buttons_cb(void *touchArea, TOUCH_ACTION triggeredAction)
Definition: button.c:92
+ + +
TOUCH_CALLBACK callback
Callback which is executed when an event occurred in this Area.
Definition: touch.h:78
+ +
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
+
void gui_button_remove(BUTTON_STRUCT *button)
Definition: button.c:184
+
void calculate_shadows(uint16_t bgcolor, uint16_t *light_shadow, uint16_t *dark_shadow)
Definition: button.c:34
+
void tft_fill_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:67
+
TOUCH_ACTION hookedActions
Actions to listen to.
Definition: touch.h:73
+
BUTTON_CALLBACK callback
Callback which is executed when the button is pressed.
Definition: button.h:58
+
bool touch_have_empty(unsigned char num)
Definition: touch.c:165
+
uint8_t font
The number of the font to use.
Definition: button.h:60
+
#define BRIGHTNESS_VAL
+
Receive an event when the pen leaves the region (pen was inside region before)
Definition: touch.h:57
+
+ + + + diff --git a/button_8h.html b/button_8h.html index 8f6337e..b1b9b51 100644 --- a/button_8h.html +++ b/button_8h.html @@ -140,7 +140,7 @@ Functions diff --git a/button_8h_source.html b/button_8h_source.html index dadd5a4..0da8c38 100644 --- a/button_8h_source.html +++ b/button_8h_source.html @@ -89,56 +89,74 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
button.h
-Go to the documentation of this file.
1 #ifndef BUTTON_H
-
2 #define BUTTON_H
-
3 
-
4 #include "touch.h"
-
5 
-
11 
-
19 
-
24 
-
25 
-
31 typedef void (*BUTTON_CALLBACK)(void *button);
-
32 
-
33 
-
37 typedef struct {
- -
39  uint16_t bgcolor;
- -
41  uint16_t txtcolor;
-
42  uint8_t font;
-
43  const char *text;
- -
45 
-
46 
-
47 #define AUTO 0
-
48 
-
49 
-
54 bool gui_button_add(BUTTON_STRUCT* button);
-
55 
-
60 void gui_button_remove(BUTTON_STRUCT* button);
-
61 
-
66 void gui_button_redraw(BUTTON_STRUCT* button);
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/gui/button.h
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-04-27 timolang@gmail.com 7c9eabc Added button support.
+
11 * 2015-04-27 timolang@gmail.com cf72baa Introduced a Screen (sub) module and divided app into multiple screens.
+
12 * 2015-05-11 timolang@gmail.com 08d9fe0 More work on doxygen module structure
+
13 * 2015-05-12 timolang@gmail.com 1402598 Added doxygen stuff for button module and some minor changes to touch, screen_main and tft module.
+
14 * 2015-05-15 timolang@gmail.com 9a16865 Added doxgen comments to filesyste, checkbox, numupdown and screen module. And some minor changes to the other modules.
+
15 * 2015-05-17 timolang@gmail.com 2d46336 Improved comments in implementation of button, checkbox, numupdown, tft, touch and screen modules/submodules.
+
16 *
+
17 **************************************************************************************************************************************/
+
18 
+
19 #ifndef BUTTON_H
+
20 #define BUTTON_H
+
21 
+
22 #include "touch.h"
+
23 
+
29 
+
37 
+
42 
+
43 
+
49 typedef void (*BUTTON_CALLBACK)(void* button);
+
50 
+
51 
+
55 typedef struct {
+ +
57  uint16_t bgcolor;
+ +
59  uint16_t txtcolor;
+
60  uint8_t font;
+
61  const char* text;
+ +
63 
+
64 
+
65 #define AUTO 0
+
66 
67 
-
68 
-
71 #endif /* BUTTON_H */
-
const char * text
The label of the button.
Definition: button.h:43
-
void gui_button_redraw(BUTTON_STRUCT *button)
Definition: button.c:130
-
uint16_t txtcolor
The 16-bit text color.
Definition: button.h:41
-
Definition: button.h:37
-
bool gui_button_add(BUTTON_STRUCT *button)
Definition: button.c:99
-
uint16_t bgcolor
The 16-bit background color of the button.
Definition: button.h:39
-
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:38
-
Definition: touch.h:50
+
72 bool gui_button_add(BUTTON_STRUCT* button);
+
73 
+
78 void gui_button_remove(BUTTON_STRUCT* button);
+
79 
+
84 void gui_button_redraw(BUTTON_STRUCT* button);
+
85 
+
86 
+
89 #endif /* BUTTON_H */
+
const char * text
The label of the button.
Definition: button.h:61
+
void gui_button_redraw(BUTTON_STRUCT *button)
Definition: button.c:164
+
uint16_t txtcolor
The 16-bit text color.
Definition: button.h:59
+ +
bool gui_button_add(BUTTON_STRUCT *button)
Definition: button.c:133
+
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
+ -
void gui_button_remove(BUTTON_STRUCT *button)
Definition: button.c:150
-
BUTTON_CALLBACK callback
Callback which is executed when the button is pressed.
Definition: button.h:40
-
uint8_t font
The number of the font to use.
Definition: button.h:42
-
void(* BUTTON_CALLBACK)(void *button)
Definition: button.h:31
+
void gui_button_remove(BUTTON_STRUCT *button)
Definition: button.c:184
+
BUTTON_CALLBACK callback
Callback which is executed when the button is pressed.
Definition: button.h:58
+
uint8_t font
The number of the font to use.
Definition: button.h:60
+
void(* BUTTON_CALLBACK)(void *button)
Definition: button.h:49
diff --git a/checkbox_8c.html b/checkbox_8c.html index 0590e4e..38bc79a 100644 --- a/checkbox_8c.html +++ b/checkbox_8c.html @@ -103,7 +103,9 @@ Include dependency graph for checkbox.c:
- + +

Go to the source code of this file.

+
@@ -137,6 +139,8 @@ Functions

Macros

#define ACTIVE_COLOR   RGB(251,208,123)
+

Definition at line 29 of file checkbox.c.

+
@@ -149,6 +153,8 @@ Functions
+

Definition at line 31 of file checkbox.c.

+
@@ -161,6 +167,8 @@ Functions
+

Definition at line 30 of file checkbox.c.

+

Function Documentation

@@ -188,6 +196,59 @@ Functions
+

Definition at line 34 of file checkbox.c.

+
35 {
+
36  TOUCH_AREA_STRUCT* area = (TOUCH_AREA_STRUCT*)touchArea;
+
37  CHECKBOX_STRUCT* checkbox = (CHECKBOX_STRUCT*)touchArea;
+
38 
+
39  switch (triggeredAction) {
+
40  case PEN_DOWN: //If the user touches the area for the "first time"
+
41  area->hookedActions = PEN_UP | PEN_LEAVE; //for the future we only want PEN_UP and PEN_LEAVE events
+
42 
+
43  //Draw active shadows
+
44  tft_draw_rectangle(checkbox->base.x1 + 1, checkbox->base.y1 + 1, checkbox->base.x2 - 1, checkbox->base.y2 - 1, ACTIVE_COLOR);
+
45  tft_draw_rectangle(checkbox->base.x1 + 2, checkbox->base.y1 + 2, checkbox->base.x2 - 2, checkbox->base.y2 - 2, ACTIVE_COLOR);
+
46  break;
+
47 
+
48  case PEN_UP: //If the user took the pen away, while in the area (=toggle checkbox!)
+
49  checkbox->checked = !checkbox->checked; //Toggle checkbox state
+
50  gui_checkbox_update(checkbox); //redraw/overdraw tickmark
+
51 
+
52  if (checkbox->callback != NULL) { //The user provided a callback
+
53  checkbox->callback(checkbox, checkbox->checked); //Call the provided callback with the new checked state
+
54  }
+
55 
+
56  // no break statement here!
+
57  case PEN_LEAVE: //if the user "slided out" of the area
+
58  area->hookedActions = PEN_DOWN; //for the future we only want PEN_DOWN events
+
59 
+
60  //Draw inactive shadows
+
61  tft_draw_rectangle(checkbox->base.x1 + 1, checkbox->base.y1 + 1, checkbox->base.x2 - 1, checkbox->base.y2 - 1, BACKGROUND_COLOR);
+
62  tft_draw_rectangle(checkbox->base.x1 + 2, checkbox->base.y1 + 2, checkbox->base.x2 - 2, checkbox->base.y2 - 2, BACKGROUND_COLOR);
+
63  break;
+
64 
+
65  default:
+
66  break;
+
67  }
+
68 }
+
Receive an event when the pen goes down inside the region.
Definition: touch.h:54
+
Receive an event when the pen goes up inside the region.
Definition: touch.h:55
+
#define ACTIVE_COLOR
Definition: checkbox.c:29
+
uint16_t y1
Top Left Y-Coordinate of Area.
Definition: touch.h:75
+
void gui_checkbox_update(CHECKBOX_STRUCT *checkbox)
Definition: checkbox.c:125
+
#define BACKGROUND_COLOR
Definition: checkbox.c:31
+
uint16_t x1
Top Left X-Coordinate of Area.
Definition: touch.h:74
+
bool checked
A boolean which indicates whether or not the checkbox is currently checked.
Definition: checkbox.h:53
+ +
uint16_t y2
Bottom Right Y-Coordinate of Area.
Definition: touch.h:77
+ +
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
+
TOUCH_ACTION hookedActions
Actions to listen to.
Definition: touch.h:73
+
void tft_draw_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:61
+
TOUCH_AREA_STRUCT base
Basic geometry of the Checkbox. You only need to set the x1, y1, x2, y2 members of this struct...
Definition: checkbox.h:51
+
CHECKBOX_CALLBACK callback
Callback which is executed when the checkbox changes state.
Definition: checkbox.h:54
+
Receive an event when the pen leaves the region (pen was inside region before)
Definition: touch.h:57
+

Here is the call graph for this function:
@@ -211,7 +272,7 @@ Here is the caller graph for this function:
diff --git a/checkbox_8c_source.html b/checkbox_8c_source.html new file mode 100644 index 0000000..1bbcfec --- /dev/null +++ b/checkbox_8c_source.html @@ -0,0 +1,277 @@ + + + + + + +discoverpixy: common/gui/checkbox.c Source File + + + + + + + + + + +
+
+ + + + + + +
+
discoverpixy +
+
+
+ + + + + + +
+
+ + +
+ +
+ + +
+
+
+
checkbox.c
+
+
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/gui/checkbox.c
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-04-27 timolang@gmail.com b300ac5 Added Checkbox support
+
11 * 2015-05-17 timolang@gmail.com 2d46336 Improved comments in implementation of button, checkbox, numupdown, tft, touch and screen modules/submodules.
+
12 *
+
13 **************************************************************************************************************************************/
+
14 
+
15 #include "tft.h"
+
16 #include "touch.h"
+
17 #include "checkbox.h"
+
18 #include <stdio.h>
+
19 
+
20 /* The idea is as follows:
+
21  * When the user creates a checkbox we create a touch area for that region and wait for PEN_DOWN events.
+
22  * Once the user puts the pen down in this area we'll redraw the checkbox with different shadows (feedback)
+
23  * and we'll now wait on PEN_UP or PEN_LEAVE events.
+
24  * If the user takes the pen away while in the area (PEN_UP), we toggle the checkbox and we call the provided user callback
+
25  * Otherwise (PEN_LEAVE) we only restore the initial shadows
+
26  */
+
27 
+
28 
+
29 #define ACTIVE_COLOR RGB(251,208,123) //shadow color (inside of border)
+
30 #define BORDER_COLOR RGB(29,82,129) //1px border color
+
31 #define BACKGROUND_COLOR WHITE //Background color
+
32 
+
33 //Callback which is called when the user touches the touch-area we created for the checkbox
+
34 void checkboxes_cb(void* touchArea, TOUCH_ACTION triggeredAction)
+
35 {
+
36  TOUCH_AREA_STRUCT* area = (TOUCH_AREA_STRUCT*)touchArea;
+
37  CHECKBOX_STRUCT* checkbox = (CHECKBOX_STRUCT*)touchArea;
+
38 
+
39  switch (triggeredAction) {
+
40  case PEN_DOWN: //If the user touches the area for the "first time"
+
41  area->hookedActions = PEN_UP | PEN_LEAVE; //for the future we only want PEN_UP and PEN_LEAVE events
+
42 
+
43  //Draw active shadows
+
44  tft_draw_rectangle(checkbox->base.x1 + 1, checkbox->base.y1 + 1, checkbox->base.x2 - 1, checkbox->base.y2 - 1, ACTIVE_COLOR);
+
45  tft_draw_rectangle(checkbox->base.x1 + 2, checkbox->base.y1 + 2, checkbox->base.x2 - 2, checkbox->base.y2 - 2, ACTIVE_COLOR);
+
46  break;
+
47 
+
48  case PEN_UP: //If the user took the pen away, while in the area (=toggle checkbox!)
+
49  checkbox->checked = !checkbox->checked; //Toggle checkbox state
+
50  gui_checkbox_update(checkbox); //redraw/overdraw tickmark
+
51 
+
52  if (checkbox->callback != NULL) { //The user provided a callback
+
53  checkbox->callback(checkbox, checkbox->checked); //Call the provided callback with the new checked state
+
54  }
+
55 
+
56  // no break statement here!
+
57  case PEN_LEAVE: //if the user "slided out" of the area
+
58  area->hookedActions = PEN_DOWN; //for the future we only want PEN_DOWN events
+
59 
+
60  //Draw inactive shadows
+
61  tft_draw_rectangle(checkbox->base.x1 + 1, checkbox->base.y1 + 1, checkbox->base.x2 - 1, checkbox->base.y2 - 1, BACKGROUND_COLOR);
+
62  tft_draw_rectangle(checkbox->base.x1 + 2, checkbox->base.y1 + 2, checkbox->base.x2 - 2, checkbox->base.y2 - 2, BACKGROUND_COLOR);
+
63  break;
+
64 
+
65  default:
+
66  break;
+
67  }
+
68 }
+
69 
+ +
71 {
+
72  if (touch_have_empty(1)) { //Check if the touch module can handle one additional area
+
73  unsigned char size = 0;
+
74  checkbox->base.hookedActions = PEN_DOWN; //At first we are interested in PEN_DOWN events
+
75  checkbox->base.callback = checkboxes_cb; //Use our own callback for the touch area events
+
76 
+
77  //Check the size of the checkbox
+
78  if (checkbox->base.x2 > checkbox->base.x1) {
+
79  size = checkbox->base.x2 - checkbox->base.x1; //use width a as size
+
80  }
+
81 
+
82  if (checkbox->base.y2 > checkbox->base.y1) {
+
83  if ((checkbox->base.y2 - checkbox->base.y1) > size) { //height is larger than size
+
84  size = checkbox->base.y2 - checkbox->base.y1; //use height as size
+
85  }
+
86  }
+
87 
+
88  if (size == 0) { //no size found (maybe swap x2 and x1 or y2 and y1 ?)
+
89  return false; //signal error
+
90  }
+
91 
+
92  if ((size & 0x01)) { //the size is an odd number
+
93  size++; //make size an even number
+
94  }
+
95 
+
96  //Correct x2,y2 so that the checkbox is quadratic
+
97  checkbox->base.x2 = checkbox->base.x1 + size;
+
98  checkbox->base.y2 = checkbox->base.y1 + size;
+
99 
+
100  gui_checkbox_redraw(checkbox);//Call redraw method, which will take care of the drawing of the entire checkbox
+
101 
+
102  return touch_register_area(&checkbox->base); //Register the touch area and receive events for this checkbox, from now on
+
103  }
+
104 
+
105  return false; //no more touch areas left
+
106 }
+
107 
+ +
109 {
+
110  //Draw background and border
+
111  tft_fill_rectangle(checkbox->base.x1 + 1, checkbox->base.y1 + 1, checkbox->base.x2 - 1, checkbox->base.y2 - 1, BACKGROUND_COLOR);
+
112  tft_draw_rectangle(checkbox->base.x1, checkbox->base.y1, checkbox->base.x2, checkbox->base.y2, BORDER_COLOR);
+
113 
+
114  if (checkbox->checked) { //checkbox is currently checked
+
115  gui_checkbox_update(checkbox); //Call update method which will draw the tickmark
+
116  }
+
117 }
+
118 
+ +
120 {
+
121  //We only need to unregister the touch area, as we have not allocated anything else
+ +
123 }
+
124 
+ +
126 {
+
127  unsigned int c = (checkbox->checked) ? checkbox->fgcolor : BACKGROUND_COLOR; //color to use for the tickmark
+
128 
+
129  //helper points inside the checkbox
+
130  unsigned int xcent = checkbox->base.x1 + (checkbox->base.x2 - checkbox->base.x1) * 6 / 14;
+
131  unsigned int yleft = checkbox->base.y2 - (xcent - checkbox->base.x1) - 1 ;
+
132  unsigned int yright = checkbox->base.y2 - (checkbox->base.x2 - xcent) - 1 ;
+
133  unsigned int ybot = checkbox->base.y2 - 4;
+
134 
+
135  //Draw tickmark as a 3pixel wide line
+
136  tft_draw_line(checkbox->base.x1 + 3, yleft - 1, xcent, ybot - 1, c);
+
137  tft_draw_line(checkbox->base.x1 + 3, yleft, xcent, ybot , c);
+
138  tft_draw_line(checkbox->base.x1 + 3, yleft + 1, xcent, ybot + 1, c);
+
139  xcent++;
+
140  ybot--;
+
141  tft_draw_line(xcent, ybot - 1, checkbox->base.x2 - 3, yright - 1, c);
+
142  tft_draw_line(xcent, ybot, checkbox->base.x2 - 3, yright + 0, c);
+
143  tft_draw_line(xcent, ybot + 1, checkbox->base.x2 - 3, yright + 1, c);
+
144 }
+
TOUCH_ACTION
Definition: touch.h:52
+
bool touch_register_area(TOUCH_AREA_STRUCT *area)
Definition: touch.c:181
+
Receive an event when the pen goes down inside the region.
Definition: touch.h:54
+
Receive an event when the pen goes up inside the region.
Definition: touch.h:55
+
bool gui_checkbox_add(CHECKBOX_STRUCT *checkbox)
Definition: checkbox.c:70
+
void tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:50
+
#define ACTIVE_COLOR
Definition: checkbox.c:29
+
uint16_t y1
Top Left Y-Coordinate of Area.
Definition: touch.h:75
+
void gui_checkbox_update(CHECKBOX_STRUCT *checkbox)
Definition: checkbox.c:125
+
#define BACKGROUND_COLOR
Definition: checkbox.c:31
+
void gui_checkbox_remove(CHECKBOX_STRUCT *checkbox)
Definition: checkbox.c:119
+
uint16_t x1
Top Left X-Coordinate of Area.
Definition: touch.h:74
+
bool checked
A boolean which indicates whether or not the checkbox is currently checked.
Definition: checkbox.h:53
+
void touch_unregister_area(TOUCH_AREA_STRUCT *area)
Definition: touch.c:195
+ + +
uint16_t y2
Bottom Right Y-Coordinate of Area.
Definition: touch.h:77
+ + +
TOUCH_CALLBACK callback
Callback which is executed when an event occurred in this Area.
Definition: touch.h:78
+ +
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
+
void tft_fill_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:67
+
TOUCH_ACTION hookedActions
Actions to listen to.
Definition: touch.h:73
+
void tft_draw_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:61
+
#define BORDER_COLOR
Definition: checkbox.c:30
+
TOUCH_AREA_STRUCT base
Basic geometry of the Checkbox. You only need to set the x1, y1, x2, y2 members of this struct...
Definition: checkbox.h:51
+
uint16_t fgcolor
The 16-bit color of the tickmark.
Definition: checkbox.h:52
+
bool touch_have_empty(unsigned char num)
Definition: touch.c:165
+
void gui_checkbox_redraw(CHECKBOX_STRUCT *checkbox)
Definition: checkbox.c:108
+
void checkboxes_cb(void *touchArea, TOUCH_ACTION triggeredAction)
Definition: checkbox.c:34
+
CHECKBOX_CALLBACK callback
Callback which is executed when the checkbox changes state.
Definition: checkbox.h:54
+
Receive an event when the pen leaves the region (pen was inside region before)
Definition: touch.h:57
+
+ + + + diff --git a/checkbox_8h.html b/checkbox_8h.html index c30de66..c583a65 100644 --- a/checkbox_8h.html +++ b/checkbox_8h.html @@ -141,7 +141,7 @@ Functions diff --git a/checkbox_8h_source.html b/checkbox_8h_source.html index 2b93fc8..ba8680e 100644 --- a/checkbox_8h_source.html +++ b/checkbox_8h_source.html @@ -89,50 +89,66 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
checkbox.h
-Go to the documentation of this file.
1 #ifndef CHECKBOX_H
-
2 #define CHECKBOX_H
-
3 
-
4 #include "touch.h"
-
5 
-
10 
-
17 
-
22 
-
29 typedef void (*CHECKBOX_CALLBACK)(void *checkbox, bool checked);
-
30 
-
34 typedef struct {
- -
36  uint16_t fgcolor;
-
37  bool checked;
- - -
40 
-
46 bool gui_checkbox_add(CHECKBOX_STRUCT* checkbox);
-
47 
-
52 void gui_checkbox_remove(CHECKBOX_STRUCT* checkbox);
-
53 
-
58 void gui_checkbox_update(CHECKBOX_STRUCT* checkbox);
-
59 
-
64 void gui_checkbox_redraw(CHECKBOX_STRUCT* checkbox);
-
65 
-
66 #define CHECKBOX_WIN_FG_COLOR RGB(32,161,34)
-
67 
-
70 #endif /* CHECKBOX_H */
-
bool gui_checkbox_add(CHECKBOX_STRUCT *checkbox)
Definition: checkbox.c:51
-
void gui_checkbox_update(CHECKBOX_STRUCT *checkbox)
Definition: checkbox.c:102
-
void gui_checkbox_remove(CHECKBOX_STRUCT *checkbox)
Definition: checkbox.c:96
-
bool checked
A boolean which indicates whether or not the checkbox is currently checked.
Definition: checkbox.h:37
-
Definition: touch.h:50
-
Definition: checkbox.h:34
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/gui/checkbox.h
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-04-27 timolang@gmail.com b300ac5 Added Checkbox support
+
11 * 2015-05-11 timolang@gmail.com 08d9fe0 More work on doxygen module structure
+
12 * 2015-05-15 timolang@gmail.com 9a16865 Added doxgen comments to filesyste, checkbox, numupdown and screen module. And some minor changes to the other modules.
+
13 * 2015-05-17 timolang@gmail.com 2d46336 Improved comments in implementation of button, checkbox, numupdown, tft, touch and screen modules/submodules.
+
14 *
+
15 **************************************************************************************************************************************/
+
16 
+
17 #ifndef CHECKBOX_H
+
18 #define CHECKBOX_H
+
19 
+
20 #include "touch.h"
+
21 
+
26 
+
33 
+
38 
+
45 typedef void (*CHECKBOX_CALLBACK)(void* checkbox, bool checked);
+
46 
+
50 typedef struct {
+ +
52  uint16_t fgcolor;
+
53  bool checked;
+ + +
56 
+
62 bool gui_checkbox_add(CHECKBOX_STRUCT* checkbox);
+
63 
+
68 void gui_checkbox_remove(CHECKBOX_STRUCT* checkbox);
+
69 
+
74 void gui_checkbox_update(CHECKBOX_STRUCT* checkbox);
+
75 
+
80 void gui_checkbox_redraw(CHECKBOX_STRUCT* checkbox);
+
81 
+
82 #define CHECKBOX_WIN_FG_COLOR RGB(32,161,34)
+
83 
+
86 #endif /* CHECKBOX_H */
+
bool gui_checkbox_add(CHECKBOX_STRUCT *checkbox)
Definition: checkbox.c:70
+
void gui_checkbox_update(CHECKBOX_STRUCT *checkbox)
Definition: checkbox.c:125
+
void gui_checkbox_remove(CHECKBOX_STRUCT *checkbox)
Definition: checkbox.c:119
+
bool checked
A boolean which indicates whether or not the checkbox is currently checked.
Definition: checkbox.h:53
+ + -
TOUCH_AREA_STRUCT base
Basic geometry of the Checkbox. You only need to set the x1, y1, x2, y2 members of this struct...
Definition: checkbox.h:35
-
void(* CHECKBOX_CALLBACK)(void *checkbox, bool checked)
Definition: checkbox.h:29
-
uint16_t fgcolor
The 16-bit color of the tickmark.
Definition: checkbox.h:36
-
void gui_checkbox_redraw(CHECKBOX_STRUCT *checkbox)
Definition: checkbox.c:85
-
CHECKBOX_CALLBACK callback
Callback which is executed when the checkbox changes state.
Definition: checkbox.h:38
+
TOUCH_AREA_STRUCT base
Basic geometry of the Checkbox. You only need to set the x1, y1, x2, y2 members of this struct...
Definition: checkbox.h:51
+
void(* CHECKBOX_CALLBACK)(void *checkbox, bool checked)
Definition: checkbox.h:45
+
uint16_t fgcolor
The 16-bit color of the tickmark.
Definition: checkbox.h:52
+
void gui_checkbox_redraw(CHECKBOX_STRUCT *checkbox)
Definition: checkbox.c:108
+
CHECKBOX_CALLBACK callback
Callback which is executed when the checkbox changes state.
Definition: checkbox.h:54
diff --git a/classes.html b/classes.html index 528c1b5..520c06c 100644 --- a/classes.html +++ b/classes.html @@ -109,7 +109,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
diff --git a/dir_000001_000002.html b/dir_000001_000002.html index d17be9d..70e7409 100644 --- a/dir_000001_000002.html +++ b/dir_000001_000002.html @@ -82,7 +82,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

app → filesystem Relation

File in common/appIncludes file in common/filesystem
app.cfilesystem.h
pixy_frame.hfilesystem.h
screen_filetest.cfilesystem.h
screen_main.cfilesystem.h
screen_photomode_save.cfilesystem.h
diff --git a/dir_000001_000003.html b/dir_000001_000003.html index d476378..6aadbd1 100644 --- a/dir_000001_000003.html +++ b/dir_000001_000003.html @@ -82,7 +82,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

app → gui Relation

File in common/appIncludes file in common/gui
screen_filetest.cbutton.h
screen_filetest.hscreen.h
screen_guitest.cbutton.h
screen_guitest.ccheckbox.h
screen_guitest.cnumupdown.h
screen_guitest.hscreen.h
screen_main.cbutton.h
screen_main.hscreen.h
screen_photomode.cbutton.h
screen_photomode.hscreen.h
screen_photomode_save.cbutton.h
screen_photomode_save.hscreen.h
screen_pixytest.cbutton.h
screen_pixytest.cnumupdown.h
screen_pixytest.hscreen.h
screen_tracking.cbutton.h
screen_tracking.ccheckbox.h
screen_tracking.hscreen.h
diff --git a/dir_000001_000005.html b/dir_000001_000005.html index 67965bf..de78ef0 100644 --- a/dir_000001_000005.html +++ b/dir_000001_000005.html @@ -82,7 +82,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

app → pixy Relation

File in common/appIncludes file in common/pixy
pixy_frame.cpixy.h
screen_photomode.cpixy.h
screen_photomode_save.cpixy.h
screen_pixytest.cpixy.h
screen_tracking.cpixy.h
diff --git a/dir_000001_000006.html b/dir_000001_000006.html index 16e75de..708f0c2 100644 --- a/dir_000001_000006.html +++ b/dir_000001_000006.html @@ -82,7 +82,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

app → system Relation

File in common/appIncludes file in common/system
app.csystem.h
screen_photomode.csystem.h
screen_pixytest.csystem.h
screen_tracking.csystem.h
diff --git a/dir_000001_000007.html b/dir_000001_000007.html index 0cc9173..72d2720 100644 --- a/dir_000001_000007.html +++ b/dir_000001_000007.html @@ -82,7 +82,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

app → tft Relation

File in common/appIncludes file in common/tft
app.ctft.h
pixy_frame.ctft.h
screen_filetest.ctft.h
screen_guitest.ctft.h
screen_main.ctft.h
screen_photomode.ctft.h
screen_photomode_save.ctft.h
screen_pixytest.ctft.h
screen_tracking.ctft.h
diff --git a/dir_000001_000008.html b/dir_000001_000008.html index d4186a8..6c62214 100644 --- a/dir_000001_000008.html +++ b/dir_000001_000008.html @@ -82,7 +82,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

app → touch Relation

File in common/appIncludes file in common/touch
app.ctouch.h
screen_photomode.ctouch.h
screen_photomode_save.ctouch.h
screen_pixytest.ctouch.h
screen_tracking.ctouch.h
diff --git a/dir_000002_000004.html b/dir_000002_000004.html index 84646d1..2a543ff 100644 --- a/dir_000002_000004.html +++ b/dir_000002_000004.html @@ -82,7 +82,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

filesystem → lowlevel Relation

File in common/filesystemIncludes file in common/lowlevel
filesystem.cll_filesystem.h
diff --git a/dir_000003_000007.html b/dir_000003_000007.html index dda763f..949927d 100644 --- a/dir_000003_000007.html +++ b/dir_000003_000007.html @@ -82,7 +82,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

gui → tft Relation

File in common/guiIncludes file in common/tft
button.ctft.h
checkbox.ctft.h
numupdown.ctft.h
diff --git a/dir_000003_000008.html b/dir_000003_000008.html index 07b4f12..bff9b10 100644 --- a/dir_000003_000008.html +++ b/dir_000003_000008.html @@ -82,7 +82,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

gui → touch Relation

File in common/guiIncludes file in common/touch
button.ctouch.h
button.htouch.h
checkbox.ctouch.h
checkbox.htouch.h
numupdown.ctouch.h
diff --git a/dir_000004_000002.html b/dir_000004_000002.html index 2fe25e5..025f8cd 100644 --- a/dir_000004_000002.html +++ b/dir_000004_000002.html @@ -82,7 +82,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

lowlevel → filesystem Relation

File in common/lowlevelIncludes file in common/filesystem
ll_filesystem.hfilesystem.h
diff --git a/dir_000006_000004.html b/dir_000006_000004.html index c23f8c1..455a382 100644 --- a/dir_000006_000004.html +++ b/dir_000006_000004.html @@ -82,7 +82,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

system → lowlevel Relation

File in common/systemIncludes file in common/lowlevel
system.cll_system.h
diff --git a/dir_000007_000002.html b/dir_000007_000002.html index 35513b6..2fc7ffb 100644 --- a/dir_000007_000002.html +++ b/dir_000007_000002.html @@ -82,7 +82,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

tft → filesystem Relation

File in common/tftIncludes file in common/filesystem
tft.cfilesystem.h
diff --git a/dir_000007_000004.html b/dir_000007_000004.html index 094721c..20179d6 100644 --- a/dir_000007_000004.html +++ b/dir_000007_000004.html @@ -82,7 +82,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

tft → lowlevel Relation

File in common/tftIncludes file in common/lowlevel
tft.cll_tft.h
diff --git a/dir_000008_000003.html b/dir_000008_000003.html index 50fa995..9845df7 100644 --- a/dir_000008_000003.html +++ b/dir_000008_000003.html @@ -82,7 +82,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

touch → gui Relation

File in common/touchIncludes file in common/gui
screen_calibrate.hscreen.h
diff --git a/dir_000008_000004.html b/dir_000008_000004.html index 6e4d9e7..21f1182 100644 --- a/dir_000008_000004.html +++ b/dir_000008_000004.html @@ -82,7 +82,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

touch → lowlevel Relation

File in common/touchIncludes file in common/lowlevel
touch.cll_touch.h
diff --git a/dir_000008_000007.html b/dir_000008_000007.html index 849ff06..5da1c8b 100644 --- a/dir_000008_000007.html +++ b/dir_000008_000007.html @@ -82,7 +82,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

touch → tft Relation

File in common/touchIncludes file in common/tft
screen_calibrate.ctft.h
diff --git a/dir_0a50ab14f1d261d61cd33403a26c32cc.html b/dir_0a50ab14f1d261d61cd33403a26c32cc.html index d99efde..090f4d8 100644 --- a/dir_0a50ab14f1d261d61cd33403a26c32cc.html +++ b/dir_0a50ab14f1d261d61cd33403a26c32cc.html @@ -93,7 +93,7 @@ Directory dependency graph for filesystem: - + @@ -101,7 +101,7 @@ Files diff --git a/dir_284aa68f6d81a4e6cef9d8d6fca4af3e.html b/dir_284aa68f6d81a4e6cef9d8d6fca4af3e.html index 3e87e11..e8e389e 100644 --- a/dir_284aa68f6d81a4e6cef9d8d6fca4af3e.html +++ b/dir_284aa68f6d81a4e6cef9d8d6fca4af3e.html @@ -93,7 +93,7 @@ Directory dependency graph for system:

Files

file  filesystem.c
file  filesystem.c [code]
 
file  filesystem.h [code]
 
- + @@ -101,7 +101,7 @@ Files diff --git a/dir_4298a0eb495ff7ff4bd3a3a3e6ccf3f0.html b/dir_4298a0eb495ff7ff4bd3a3a3e6ccf3f0.html index 0a020ea..70b4574 100644 --- a/dir_4298a0eb495ff7ff4bd3a3a3e6ccf3f0.html +++ b/dir_4298a0eb495ff7ff4bd3a3a3e6ccf3f0.html @@ -101,7 +101,7 @@ Files diff --git a/dir_5668dfef4710d48cd9d7316a574bf987.html b/dir_5668dfef4710d48cd9d7316a574bf987.html index 0ea228b..f224c5c 100644 --- a/dir_5668dfef4710d48cd9d7316a574bf987.html +++ b/dir_5668dfef4710d48cd9d7316a574bf987.html @@ -93,11 +93,11 @@ Directory dependency graph for touch:

Files

file  system.c
file  system.c [code]
 
file  system.h [code]
 
- + - + @@ -105,7 +105,7 @@ Files diff --git a/dir_73c9649cd1892d880e57f5a32368877e.html b/dir_73c9649cd1892d880e57f5a32368877e.html index 8a4231d..737f271 100644 --- a/dir_73c9649cd1892d880e57f5a32368877e.html +++ b/dir_73c9649cd1892d880e57f5a32368877e.html @@ -105,7 +105,7 @@ Files diff --git a/dir_99a8943037ff3844556e6a5d529fec0c.html b/dir_99a8943037ff3844556e6a5d529fec0c.html index 320f062..0b26b81 100644 --- a/dir_99a8943037ff3844556e6a5d529fec0c.html +++ b/dir_99a8943037ff3844556e6a5d529fec0c.html @@ -93,43 +93,43 @@ Directory dependency graph for app:

Files

file  screen_calibrate.c
file  screen_calibrate.c [code]
 
file  screen_calibrate.h [code]
 
file  touch.c
file  touch.c [code]
 
file  touch.h [code]
 
- + - + - + - + - + - + - + - + - + - + @@ -137,7 +137,7 @@ Files diff --git a/dir_ad7e3681fbb6f77d8ce503c4a3117735.html b/dir_ad7e3681fbb6f77d8ce503c4a3117735.html index a83f8f1..7390638 100644 --- a/dir_ad7e3681fbb6f77d8ce503c4a3117735.html +++ b/dir_ad7e3681fbb6f77d8ce503c4a3117735.html @@ -93,19 +93,19 @@ Directory dependency graph for gui:

Files

file  app.c
file  app.c [code]
 
file  app.h [code]
 
file  pixy_control.c
file  pixy_control.c [code]
 
file  pixy_control.h [code]
 
file  pixy_frame.c
file  pixy_frame.c [code]
 
file  pixy_frame.h [code]
 
file  screen_filetest.c
file  screen_filetest.c [code]
 
file  screen_filetest.h [code]
 
file  screen_guitest.c
file  screen_guitest.c [code]
 
file  screen_guitest.h [code]
 
file  screen_main.c
file  screen_main.c [code]
 
file  screen_main.h [code]
 
file  screen_photomode.c
file  screen_photomode.c [code]
 
file  screen_photomode.h [code]
 
file  screen_photomode_save.c
file  screen_photomode_save.c [code]
 
file  screen_photomode_save.h [code]
 
file  screen_pixytest.c
file  screen_pixytest.c [code]
 
file  screen_pixytest.h [code]
 
file  screen_tracking.c
file  screen_tracking.c [code]
 
file  screen_tracking.h [code]
 
- + - + - + - + @@ -113,7 +113,7 @@ Files diff --git a/dir_bdd9a5d540de89e9fe90efdfc6973a4f.html b/dir_bdd9a5d540de89e9fe90efdfc6973a4f.html index 9ec143a..2909c8e 100644 --- a/dir_bdd9a5d540de89e9fe90efdfc6973a4f.html +++ b/dir_bdd9a5d540de89e9fe90efdfc6973a4f.html @@ -113,7 +113,7 @@ Directories diff --git a/dir_e222ac1ff707f15b04869ea0388b9123.html b/dir_e222ac1ff707f15b04869ea0388b9123.html index ece6f44..abe9827 100644 --- a/dir_e222ac1ff707f15b04869ea0388b9123.html +++ b/dir_e222ac1ff707f15b04869ea0388b9123.html @@ -93,7 +93,7 @@ Directory dependency graph for tft:

Files

file  button.c
file  button.c [code]
 
file  button.h [code]
 
file  checkbox.c
file  checkbox.c [code]
 
file  checkbox.h [code]
 
file  numupdown.c
file  numupdown.c [code]
 
file  numupdown.h [code]
 
file  screen.c
file  screen.c [code]
 
file  screen.h [code]
 
- + @@ -101,7 +101,7 @@ Files diff --git a/dynsections.js b/dynsections.js index 85e1836..1e6bf07 100644 --- a/dynsections.js +++ b/dynsections.js @@ -95,3 +95,10 @@ function toggleInherit(id) } } + +$(document).ready(function() { + $('.code,.codeRef').each(function() { + $(this).data('powertip',$('#'+$(this).attr('href').replace(/.*\//,'').replace(/[^a-z_A-Z0-9]/g,'_')).html()); + $(this).powerTip({ placement: 's', smartPlacement: true, mouseOnToPopup: true }); + }); +}); diff --git a/files.html b/files.html index ea0df10..84bea77 100644 --- a/files.html +++ b/files.html @@ -89,37 +89,37 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
[detail level 123]

Files

file  tft.c
file  tft.c [code]
 
file  tft.h [code]
 
- + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -130,22 +130,22 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); - + - + - + - +
  common
  app
 app.c
 app.c
 app.h
 pixy_control.c
 pixy_control.c
 pixy_control.h
 pixy_frame.c
 pixy_frame.c
 pixy_frame.h
 screen_filetest.c
 screen_filetest.c
 screen_filetest.h
 screen_guitest.c
 screen_guitest.c
 screen_guitest.h
 screen_main.c
 screen_main.c
 screen_main.h
 screen_photomode.c
 screen_photomode.c
 screen_photomode.h
 screen_photomode_save.c
 screen_photomode_save.c
 screen_photomode_save.h
 screen_pixytest.c
 screen_pixytest.c
 screen_pixytest.h
 screen_tracking.c
 screen_tracking.c
 screen_tracking.h
  filesystem
 filesystem.c
 filesystem.c
 filesystem.h
  gui
 button.c
 button.c
 button.h
 checkbox.c
 checkbox.c
 checkbox.h
 numupdown.c
 numupdown.c
 numupdown.h
 screen.c
 screen.c
 screen.h
  lowlevel
 ll_filesystem.h
 pixy.h
 pixydefs.h
  system
 system.c
 system.c
 system.h
  tft
 tft.c
 tft.c
 tft.h
  touch
 screen_calibrate.c
 screen_calibrate.c
 screen_calibrate.h
 touch.c
 touch.c
 touch.h
diff --git a/filesystem_8c.html b/filesystem_8c.html index 916e033..d34b9ae 100644 --- a/filesystem_8c.html +++ b/filesystem_8c.html @@ -100,7 +100,9 @@ Include dependency graph for filesystem.c: - + +

Go to the source code of this file.

+
@@ -123,7 +125,7 @@ Functions diff --git a/filesystem_8c_source.html b/filesystem_8c_source.html new file mode 100644 index 0000000..ce750a9 --- /dev/null +++ b/filesystem_8c_source.html @@ -0,0 +1,177 @@ + + + + + + +discoverpixy: common/filesystem/filesystem.c Source File + + + + + + + + + + +
+
+

Functions

bool filesystem_init ()
+ + + + + +
+
discoverpixy +
+
+ + + + + + + +
+
+ + +
+ +
+ + + +
+
+
filesystem.c
+
+
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/filesystem/filesystem.c
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-05-10 timolang@gmail.com e2bce8f Added filesystem module, tests and implementation for it in emulator.
+
11 * 2015-05-15 timolang@gmail.com 9a16865 Added doxgen comments to filesyste, checkbox, numupdown and screen module. And some minor changes to the other modules.
+
12 *
+
13 **************************************************************************************************************************************/
+
14 
+
15 #include "filesystem.h"
+
16 #include "ll_filesystem.h"
+
17 
+ +
19 {
+
20  return ll_filesystem_init();
+
21 }
+
22 
+ +
24 {
+
25  return ll_filesystem_dir_open(path);
+
26 }
+
27 
+ +
29 {
+ +
31 }
+
32 
+
33 FILE_HANDLE* filesystem_file_open(const char* filename)
+
34 {
+
35  return ll_filesystem_file_open(filename);
+
36 }
+
37 
+ +
39 {
+ +
41 }
+
42 
+
43 FILE_STATUS filesystem_file_seek(FILE_HANDLE* handle, uint32_t offset)
+
44 {
+
45  return ll_filesystem_file_seek(handle, offset);
+
46 }
+
47 
+
48 FILE_STATUS filesystem_file_read(FILE_HANDLE* handle, uint8_t* buf, uint32_t size)
+
49 {
+
50  return ll_filesystem_file_read(handle, buf, size);
+
51 }
+
52 
+
53 FILE_STATUS filesystem_file_write(FILE_HANDLE* handle, uint8_t* buf, uint32_t size)
+
54 {
+
55  return ll_filesystem_file_write(handle, buf, size);
+
56 }
+
FILE_STATUS filesystem_file_seek(FILE_HANDLE *handle, uint32_t offset)
Definition: filesystem.c:43
+
FILE_STATUS ll_filesystem_file_seek(FILE_HANDLE *handle, uint32_t offset)
+
bool ll_filesystem_init()
+
void ll_filesystem_file_close(FILE_HANDLE *handle)
+
FILE_STATUS ll_filesystem_file_write(FILE_HANDLE *handle, uint8_t *buf, uint32_t size)
+
FILE_STATUS ll_filesystem_file_read(FILE_HANDLE *handle, uint8_t *buf, uint32_t size)
+ +
FILE_HANDLE * filesystem_file_open(const char *filename)
Definition: filesystem.c:33
+
void filesystem_file_close(FILE_HANDLE *handle)
Definition: filesystem.c:38
+ + +
FILE_STATUS filesystem_file_write(FILE_HANDLE *handle, uint8_t *buf, uint32_t size)
Definition: filesystem.c:53
+ +
DIRECTORY_STRUCT * filesystem_dir_open(const char *path)
Definition: filesystem.c:23
+
bool filesystem_init()
Definition: filesystem.c:18
+
void ll_filesystem_dir_close(DIRECTORY_STRUCT *dir)
+
DIRECTORY_STRUCT * ll_filesystem_dir_open(const char *path)
+
FILE_STATUS
Definition: filesystem.h:90
+
FILE_HANDLE * ll_filesystem_file_open(const char *filename)
+
void filesystem_dir_close(DIRECTORY_STRUCT *dir)
Definition: filesystem.c:28
+
FILE_STATUS filesystem_file_read(FILE_HANDLE *handle, uint8_t *buf, uint32_t size)
Definition: filesystem.c:48
+
+ + + + diff --git a/filesystem_8h.html b/filesystem_8h.html index e12a43e..9e976d2 100644 --- a/filesystem_8h.html +++ b/filesystem_8h.html @@ -126,12 +126,12 @@ Data Structures

Enumerations

enum  FILE_ATTRIBUTES {
-  F_RDO =0x01, -F_HID =0x02, -F_SYS =0x04, -F_DIR =0x10, +  F_RDO = 0x01, +F_HID = 0x02, +F_SYS = 0x04, +F_DIR = 0x10,
-  F_ARC =0x20 +  F_ARC = 0x20
}   @@ -168,7 +168,7 @@ Functions diff --git a/filesystem_8h_source.html b/filesystem_8h_source.html index fa1dac8..5d31eb8 100644 --- a/filesystem_8h_source.html +++ b/filesystem_8h_source.html @@ -89,120 +89,134 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
filesystem.h
-Go to the documentation of this file.
1 #ifndef FILESYSTEM_H
-
2 #define FILESYSTEM_H
-
3 
-
4 #include <stdbool.h>
-
5 #include <stdint.h>
-
6 
-
12 
-
17 typedef enum {
-
18  F_RDO=0x01,
-
19  F_HID=0x02,
-
20  F_SYS=0x04,
-
21  F_DIR=0x10,
-
22  F_ARC=0x20
- -
24 
-
28 typedef struct {
-
29  unsigned year : 7;
-
30  unsigned month: 4;
-
31  unsigned day: 5;
- -
33 
-
37 typedef struct {
-
38  unsigned hour : 5;
-
39  unsigned min: 6;
-
40  unsigned sec: 5;
- -
42 
-
46 typedef struct {
-
47  uint32_t fsize;
- - -
50  uint8_t fattrib;
-
51  char* fname;
-
52 } FILE_STRUCT;
-
53 
-
57 typedef struct {
-
58  const char* path;
-
59  uint16_t num_files;
- - -
62 
-
66 typedef struct {
-
67  const char* fname;
-
68  uint32_t fpos;
-
69  uint32_t fsize;
-
70 } FILE_HANDLE;
-
71 
-
75 typedef enum {
-
76  F_OK,
- - - - -
81 } FILE_STATUS;
-
82 
-
88 bool filesystem_init();
-
89 
-
95 DIRECTORY_STRUCT* filesystem_dir_open(const char* path);
-
96 
- -
102 
-
108 FILE_HANDLE* filesystem_file_open(const char* filename);
-
109 
-
114 void filesystem_file_close(FILE_HANDLE* handle);
-
115 
-
122 FILE_STATUS filesystem_file_seek(FILE_HANDLE* handle, uint32_t offset);
-
123 
-
131 FILE_STATUS filesystem_file_read(FILE_HANDLE* handle, uint8_t* buf, uint32_t size);
-
132 
-
141 FILE_STATUS filesystem_file_write(FILE_HANDLE* handle, uint8_t* buf, uint32_t size);
-
142 
-
143 
-
146 #endif /* FILESYSTEM_H */
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/filesystem/filesystem.h
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-04-03 timolang@gmail.com 51089aa Refactored Project Structure for use with emulator
+
11 * 2015-05-10 timolang@gmail.com e2bce8f Added filesystem module, tests and implementation for it in emulator.
+
12 * 2015-05-15 timolang@gmail.com 9a16865 Added doxgen comments to filesyste, checkbox, numupdown and screen module. And some minor changes to the other modules.
+
13 *
+
14 **************************************************************************************************************************************/
+
15 
+
16 #ifndef FILESYSTEM_H
+
17 #define FILESYSTEM_H
+
18 
+
19 #include <stdbool.h>
+
20 #include <stdint.h>
+
21 
+
27 
+
32 typedef enum {
+
33  F_RDO = 0x01,
+
34  F_HID = 0x02,
+
35  F_SYS = 0x04,
+
36  F_DIR = 0x10,
+
37  F_ARC = 0x20
+ +
39 
+
43 typedef struct {
+
44  unsigned year : 7;
+
45  unsigned month: 4;
+
46  unsigned day: 5;
+ +
48 
+
52 typedef struct {
+
53  unsigned hour : 5;
+
54  unsigned min: 6;
+
55  unsigned sec: 5;
+ +
57 
+
61 typedef struct {
+
62  uint32_t fsize;
+ + +
65  uint8_t fattrib;
+
66  char* fname;
+
67 } FILE_STRUCT;
+
68 
+
72 typedef struct {
+
73  const char* path;
+
74  uint16_t num_files;
+ + +
77 
+
81 typedef struct {
+
82  const char* fname;
+
83  uint32_t fpos;
+
84  uint32_t fsize;
+
85 } FILE_HANDLE;
+
86 
+
90 typedef enum {
+
91  F_OK,
+ + + + +
96 } FILE_STATUS;
+
97 
+
103 bool filesystem_init();
+
104 
+
110 DIRECTORY_STRUCT* filesystem_dir_open(const char* path);
+
111 
+ +
117 
+
123 FILE_HANDLE* filesystem_file_open(const char* filename);
+
124 
+
129 void filesystem_file_close(FILE_HANDLE* handle);
+
130 
+
137 FILE_STATUS filesystem_file_seek(FILE_HANDLE* handle, uint32_t offset);
+
138 
+
146 FILE_STATUS filesystem_file_read(FILE_HANDLE* handle, uint8_t* buf, uint32_t size);
147 
-
FILE_STATUS filesystem_file_seek(FILE_HANDLE *handle, uint32_t offset)
Definition: filesystem.c:24
-
uint32_t fsize
The total file size in bytes.
Definition: filesystem.h:69
-
Definition: filesystem.h:37
-
FILE_DATE_STRUCT fdate
Last modified date.
Definition: filesystem.h:48
-
The write/read operation tried to write/read past the end of the file. This is not a fatal error...
Definition: filesystem.h:77
-
uint8_t fattrib
File/Directory Attributes.
Definition: filesystem.h:50
-
You passed invalid parameters to the function.
Definition: filesystem.h:79
-
Definition: filesystem.h:66
-
FILE_HANDLE * filesystem_file_open(const char *filename)
Definition: filesystem.c:16
-
void filesystem_file_close(FILE_HANDLE *handle)
Definition: filesystem.c:20
-
File has the archive flag set (probably unused)
Definition: filesystem.h:22
-
char * fname
File/Directory name.
Definition: filesystem.h:51
-
A lowlevel disk-error occoured. This is a fatal error.
Definition: filesystem.h:80
-
File is a system file.
Definition: filesystem.h:20
-
uint16_t num_files
Number of files/directories in this directory.
Definition: filesystem.h:59
-
FILE_STATUS filesystem_file_write(FILE_HANDLE *handle, uint8_t *buf, uint32_t size)
Definition: filesystem.c:32
-
Definition: filesystem.h:57
-
uint32_t fpos
The current byte-position in the file.
Definition: filesystem.h:68
-
File is hidden.
Definition: filesystem.h:19
-
const char * path
Directory path (absolute)
Definition: filesystem.h:58
-
Everything ok.
Definition: filesystem.h:76
-
FILE_STRUCT * files
An array with num_files FILE_STRUCT entries.
Definition: filesystem.h:60
-
Definition: filesystem.h:46
-
DIRECTORY_STRUCT * filesystem_dir_open(const char *path)
Definition: filesystem.c:8
-
It's a directory and not a file.
Definition: filesystem.h:21
-
The file can not be read/written due to access problems. This is a fatal error.
Definition: filesystem.h:78
-
bool filesystem_init()
Definition: filesystem.c:4
-
FILE_ATTRIBUTES
Definition: filesystem.h:17
-
File is readonly. You cannot write to it.
Definition: filesystem.h:18
-
Definition: filesystem.h:28
-
const char * fname
The absolute file name.
Definition: filesystem.h:67
-
FILE_STATUS
Definition: filesystem.h:75
-
void filesystem_dir_close(DIRECTORY_STRUCT *dir)
Definition: filesystem.c:12
-
FILE_TIME_STRUCT ftime
Last modified time.
Definition: filesystem.h:49
-
FILE_STATUS filesystem_file_read(FILE_HANDLE *handle, uint8_t *buf, uint32_t size)
Definition: filesystem.c:28
-
uint32_t fsize
File size in bytes. 0 for directories.
Definition: filesystem.h:47
+
156 FILE_STATUS filesystem_file_write(FILE_HANDLE* handle, uint8_t* buf, uint32_t size);
+
157 
+
158 
+
161 #endif /* FILESYSTEM_H */
+
FILE_STATUS filesystem_file_seek(FILE_HANDLE *handle, uint32_t offset)
Definition: filesystem.c:43
+
uint32_t fsize
The total file size in bytes.
Definition: filesystem.h:84
+ +
FILE_DATE_STRUCT fdate
Last modified date.
Definition: filesystem.h:63
+
The write/read operation tried to write/read past the end of the file. This is not a fatal error...
Definition: filesystem.h:92
+
uint8_t fattrib
File/Directory Attributes.
Definition: filesystem.h:65
+
You passed invalid parameters to the function.
Definition: filesystem.h:94
+ +
FILE_HANDLE * filesystem_file_open(const char *filename)
Definition: filesystem.c:33
+
void filesystem_file_close(FILE_HANDLE *handle)
Definition: filesystem.c:38
+
File has the archive flag set (probably unused)
Definition: filesystem.h:37
+
char * fname
File/Directory name.
Definition: filesystem.h:66
+
A lowlevel disk-error occoured. This is a fatal error.
Definition: filesystem.h:95
+
File is a system file.
Definition: filesystem.h:35
+
uint16_t num_files
Number of files/directories in this directory.
Definition: filesystem.h:74
+
FILE_STATUS filesystem_file_write(FILE_HANDLE *handle, uint8_t *buf, uint32_t size)
Definition: filesystem.c:53
+ +
uint32_t fpos
The current byte-position in the file.
Definition: filesystem.h:83
+
File is hidden.
Definition: filesystem.h:34
+
const char * path
Directory path (absolute)
Definition: filesystem.h:73
+
Everything ok.
Definition: filesystem.h:91
+
FILE_STRUCT * files
An array with num_files FILE_STRUCT entries.
Definition: filesystem.h:75
+ +
DIRECTORY_STRUCT * filesystem_dir_open(const char *path)
Definition: filesystem.c:23
+
It's a directory and not a file.
Definition: filesystem.h:36
+
The file can not be read/written due to access problems. This is a fatal error.
Definition: filesystem.h:93
+
bool filesystem_init()
Definition: filesystem.c:18
+
FILE_ATTRIBUTES
Definition: filesystem.h:32
+
File is readonly. You cannot write to it.
Definition: filesystem.h:33
+ +
const char * fname
The absolute file name.
Definition: filesystem.h:82
+
FILE_STATUS
Definition: filesystem.h:90
+
void filesystem_dir_close(DIRECTORY_STRUCT *dir)
Definition: filesystem.c:28
+
FILE_TIME_STRUCT ftime
Last modified time.
Definition: filesystem.h:64
+
FILE_STATUS filesystem_file_read(FILE_HANDLE *handle, uint8_t *buf, uint32_t size)
Definition: filesystem.c:48
+
uint32_t fsize
File size in bytes. 0 for directories.
Definition: filesystem.h:62
diff --git a/functions.html b/functions.html index 3d76bb9..df0dfd8 100644 --- a/functions.html +++ b/functions.html @@ -337,7 +337,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
diff --git a/functions_vars.html b/functions_vars.html index 36a4410..dc2d307 100644 --- a/functions_vars.html +++ b/functions_vars.html @@ -337,7 +337,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals.html b/globals.html index 8553412..9808dd6 100644 --- a/globals.html +++ b/globals.html @@ -149,7 +149,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_b.html b/globals_b.html index 6aaa9a4..e573877 100644 --- a/globals_b.html +++ b/globals_b.html @@ -286,7 +286,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_c.html b/globals_c.html index 58213d8..0bcffde 100644 --- a/globals_c.html +++ b/globals_c.html @@ -253,7 +253,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_d.html b/globals_d.html index 94b0a34..0f8454e 100644 --- a/globals_d.html +++ b/globals_d.html @@ -136,7 +136,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_defs.html b/globals_defs.html index 27c5d9b..0abae6e 100644 --- a/globals_defs.html +++ b/globals_defs.html @@ -509,7 +509,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_e.html b/globals_e.html index dd2094e..8b69c4d 100644 --- a/globals_e.html +++ b/globals_e.html @@ -146,7 +146,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_enum.html b/globals_enum.html index bad0461..8496e35 100644 --- a/globals_enum.html +++ b/globals_enum.html @@ -112,7 +112,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_eval.html b/globals_eval.html index 1c61cd4..ee909ce 100644 --- a/globals_eval.html +++ b/globals_eval.html @@ -270,7 +270,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_f.html b/globals_f.html index 5760935..49560cd 100644 --- a/globals_f.html +++ b/globals_f.html @@ -233,7 +233,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_func.html b/globals_func.html index 2c547d5..15dbc1b 100644 --- a/globals_func.html +++ b/globals_func.html @@ -125,7 +125,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_func_b.html b/globals_func_b.html index 9ba36ab..43b0215 100644 --- a/globals_func_b.html +++ b/globals_func_b.html @@ -188,7 +188,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_func_c.html b/globals_func_c.html index 9b3eabb..ebeb91f 100644 --- a/globals_func_c.html +++ b/globals_func_c.html @@ -132,7 +132,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_func_e.html b/globals_func_e.html index 15edd55..73977cc 100644 --- a/globals_func_e.html +++ b/globals_func_e.html @@ -127,7 +127,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_func_f.html b/globals_func_f.html index 90bac2e..e88c45f 100644 --- a/globals_func_f.html +++ b/globals_func_f.html @@ -149,7 +149,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_func_g.html b/globals_func_g.html index 92944b1..5fb454f 100644 --- a/globals_func_g.html +++ b/globals_func_g.html @@ -209,7 +209,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_func_i.html b/globals_func_i.html index 19e034d..0442c21 100644 --- a/globals_func_i.html +++ b/globals_func_i.html @@ -123,7 +123,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_func_l.html b/globals_func_l.html index 8f85df1..aa755f2 100644 --- a/globals_func_l.html +++ b/globals_func_l.html @@ -202,7 +202,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_func_n.html b/globals_func_n.html index f8da5d7..8f30c49 100644 --- a/globals_func_n.html +++ b/globals_func_n.html @@ -123,7 +123,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_func_p.html b/globals_func_p.html index 2f2b335..fa113e2 100644 --- a/globals_func_p.html +++ b/globals_func_p.html @@ -217,7 +217,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_func_r.html b/globals_func_r.html index 1ee1ece..cc88e48 100644 --- a/globals_func_r.html +++ b/globals_func_r.html @@ -120,7 +120,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_func_s.html b/globals_func_s.html index 7f058bc..c534d90 100644 --- a/globals_func_s.html +++ b/globals_func_s.html @@ -136,7 +136,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_func_t.html b/globals_func_t.html index cd5e275..2081417 100644 --- a/globals_func_t.html +++ b/globals_func_t.html @@ -233,7 +233,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_func_u.html b/globals_func_u.html index 612099e..1b99536 100644 --- a/globals_func_u.html +++ b/globals_func_u.html @@ -127,7 +127,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_g.html b/globals_g.html index 9c6119a..f3de599 100644 --- a/globals_g.html +++ b/globals_g.html @@ -218,7 +218,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_h.html b/globals_h.html index 5fab819..345fff1 100644 --- a/globals_h.html +++ b/globals_h.html @@ -126,7 +126,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_i.html b/globals_i.html index 8c5d436..3e9c6e1 100644 --- a/globals_i.html +++ b/globals_i.html @@ -154,7 +154,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_l.html b/globals_l.html index fbf6f5d..4a02273 100644 --- a/globals_l.html +++ b/globals_l.html @@ -226,7 +226,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_n.html b/globals_n.html index e577d17..64a3675 100644 --- a/globals_n.html +++ b/globals_n.html @@ -150,7 +150,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_o.html b/globals_o.html index 75af055..be6bb3b 100644 --- a/globals_o.html +++ b/globals_o.html @@ -132,7 +132,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_p.html b/globals_p.html index 1ed98aa..97cc1fd 100644 --- a/globals_p.html +++ b/globals_p.html @@ -304,7 +304,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_r.html b/globals_r.html index 52c5df2..0e97861 100644 --- a/globals_r.html +++ b/globals_r.html @@ -147,7 +147,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_s.html b/globals_s.html index cb98ab1..3d5db56 100644 --- a/globals_s.html +++ b/globals_s.html @@ -204,7 +204,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_t.html b/globals_t.html index 5206350..218c329 100644 --- a/globals_t.html +++ b/globals_t.html @@ -278,7 +278,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_type.html b/globals_type.html index 0443955..433156d 100644 --- a/globals_type.html +++ b/globals_type.html @@ -124,7 +124,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_u.html b/globals_u.html index 7c2dd4a..5e38386 100644 --- a/globals_u.html +++ b/globals_u.html @@ -172,7 +172,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_vars.html b/globals_vars.html index 7c0d97d..faca7a5 100644 --- a/globals_vars.html +++ b/globals_vars.html @@ -354,7 +354,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_w.html b/globals_w.html index 5d4c691..93981c7 100644 --- a/globals_w.html +++ b/globals_w.html @@ -126,7 +126,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_x.html b/globals_x.html index da4df94..c4279b5 100644 --- a/globals_x.html +++ b/globals_x.html @@ -129,7 +129,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/globals_y.html b/globals_y.html index ab24600..a474d4b 100644 --- a/globals_y.html +++ b/globals_y.html @@ -132,7 +132,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/graph_legend.html b/graph_legend.html index e3b5647..e5759fb 100644 --- a/graph_legend.html +++ b/graph_legend.html @@ -145,7 +145,7 @@ A yellow dashed arrow denotes a relation between a template instance and the tem diff --git a/group__app.html b/group__app.html index e660dac..e55958f 100644 --- a/group__app.html +++ b/group__app.html @@ -124,6 +124,22 @@ Functions

Starts/Initializes the app This function should be called at the top of the main function of your platform

+

Definition at line 37 of file app.c.

+
38 {
+
39  system_init();
+
40  tft_init();
+
41  touch_init();
+ +
43 
+ +
45 }
+
SCREEN_STRUCT * get_screen_main()
Definition: screen_main.c:196
+
bool gui_screen_navigate(SCREEN_STRUCT *screen)
Definition: screen.c:74
+
bool system_init()
Definition: system.c:21
+
bool filesystem_init()
Definition: filesystem.c:18
+
bool tft_init()
Definition: tft.c:39
+
bool touch_init()
Definition: touch.c:61
+

Here is the call graph for this function:
@@ -149,6 +165,15 @@ Here is the call graph for this function:

Executes one cycle of the app Call this function repeatedly from a loop inside the main function

+

Definition at line 48 of file app.c.

+
49 {
+
50 
+
51  system_process(); //Let the system handle it's pending events
+
52  gui_screen_update(); //update the currently active screen
+
53 }
+
void gui_screen_update()
Definition: screen.c:41
+
void system_process()
Definition: system.c:31
+

Here is the call graph for this function:
@@ -163,7 +188,7 @@ Here is the call graph for this function:
diff --git a/group__button.html b/group__button.html index e4d5fdf..2ba01b4 100644 --- a/group__button.html +++ b/group__button.html @@ -133,6 +133,8 @@ Functions

Use this value instead of x2, y2 in the BUTTON_STRUCT to autocalculate the button width/height.

+

Definition at line 65 of file button.h.

+

Typedef Documentation

@@ -153,6 +155,8 @@ Functions +

Definition at line 49 of file button.h.

+

Function Documentation

@@ -177,6 +181,54 @@ Functions
Returns
true on success
+

Definition at line 133 of file button.c.

+
134 {
+
135  if (touch_have_empty(1)) { //Check if the touch module can handle one additional area
+
136  //Calculate width and height of the button text
+
137  unsigned int strwidth = tft_font_width(button->font) * strlen(button->text);
+
138  unsigned char strheight = tft_font_height(button->font);
+
139 
+
140  button->base.hookedActions = PEN_DOWN; //At first we are interested in PEN_DOWN events
+
141  button->base.callback = buttons_cb; //Use our own callback for the touch area events
+
142 
+
143  if (button->base.x2 == AUTO) { //The user wants us to calculate the button width automatically
+
144  //Use string width + half of a character width as button width
+
145  button->base.x2 = button->base.x1 - 1 + strwidth + (tft_font_width(button->font) / 2);
+
146  } else if ((button->base.x2 - button->base.x1 + 1) < (strwidth + 2)) { //the provided width is too small to fit the entire text
+
147  return false; //report error
+
148  }
+
149 
+
150  if (button->base.y2 == AUTO) { //The user wants us to calculate the button height automatically
+
151  //Use one and a half character heights as button height
+
152  button->base.y2 = button->base.y1 - 1 + strheight + (strheight / 2);
+
153  } else if ((button->base.y2 - button->base.y1 + 1) < (strheight + 2)) { //the provided height is too small to fit the text
+
154  return false;
+
155  }
+
156 
+
157  gui_button_redraw(button); //call the redraw method, which will take care of drawing the entire button
+
158  return touch_register_area(&button->base); //Register the touch area and receive events for this button, from now on
+
159  }
+
160 
+
161  return false; //no more touch areas left
+
162 }
+
uint8_t tft_font_height(uint8_t fontnum)
Definition: tft.c:87
+
bool touch_register_area(TOUCH_AREA_STRUCT *area)
Definition: touch.c:181
+
const char * text
The label of the button.
Definition: button.h:61
+
uint8_t tft_font_width(uint8_t fontnum)
Definition: tft.c:92
+
void gui_button_redraw(BUTTON_STRUCT *button)
Definition: button.c:164
+
#define AUTO
Use this value instead of x2, y2 in the BUTTON_STRUCT to autocalculate the button width/height...
Definition: button.h:65
+
Receive an event when the pen goes down inside the region.
Definition: touch.h:54
+
uint16_t y1
Top Left Y-Coordinate of Area.
Definition: touch.h:75
+
uint16_t x1
Top Left X-Coordinate of Area.
Definition: touch.h:74
+
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
+
uint16_t y2
Bottom Right Y-Coordinate of Area.
Definition: touch.h:77
+
void buttons_cb(void *touchArea, TOUCH_ACTION triggeredAction)
Definition: button.c:92
+
TOUCH_CALLBACK callback
Callback which is executed when an event occurred in this Area.
Definition: touch.h:78
+
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
+
TOUCH_ACTION hookedActions
Actions to listen to.
Definition: touch.h:73
+
bool touch_have_empty(unsigned char num)
Definition: touch.c:165
+
uint8_t font
The number of the font to use.
Definition: button.h:60
+

Here is the call graph for this function:
@@ -217,6 +269,41 @@ Here is the caller graph for this function:
+

Definition at line 164 of file button.c.

+
165 {
+
166  //Calculate text dimensions and shadow colors
+
167  unsigned int strwidth = tft_font_width(button->font) * strlen(button->text);
+
168  unsigned char strheight = tft_font_height(button->font);
+
169  uint16_t c_light, c_dark;
+
170  calculate_shadows(button->bgcolor, &c_light, &c_dark);
+
171 
+
172  //Draw the background and the 4 lines (shadow colors)
+
173  tft_fill_rectangle(button->base.x1 + 1, button->base.y1 + 1, button->base.x2 - 1, button->base.y2 - 1, button->bgcolor);
+
174  tft_draw_line(button->base.x1 + 1, button->base.y1, button->base.x2 - 1, button->base.y1, c_light); //North
+
175  tft_draw_line(button->base.x1, button->base.y1 + 1, button->base.x1, button->base.y2 - 1, c_light); //West
+
176  tft_draw_line(button->base.x1 + 1, button->base.y2, button->base.x2 - 1, button->base.y2, c_dark); //South
+
177  tft_draw_line(button->base.x2, button->base.y1 + 1, button->base.x2, button->base.y2 - 1, c_dark); //East
+
178 
+
179  //Draw the text
+
180  tft_print_line(button->base.x1 + (button->base.x2 - button->base.x1 + 1 - strwidth) / 2, button->base.y1 + (button->base.y2 - button->base.y1 + 1 - strheight) / 2, button->txtcolor, button->bgcolor, button->font, button->text);
+
181 
+
182 }
+
uint8_t tft_font_height(uint8_t fontnum)
Definition: tft.c:87
+
const char * text
The label of the button.
Definition: button.h:61
+
uint8_t tft_font_width(uint8_t fontnum)
Definition: tft.c:92
+
uint16_t txtcolor
The 16-bit text color.
Definition: button.h:59
+
void tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:50
+
uint16_t y1
Top Left Y-Coordinate of Area.
Definition: touch.h:75
+
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
+
uint16_t x1
Top Left X-Coordinate of Area.
Definition: touch.h:74
+
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
+
uint16_t y2
Bottom Right Y-Coordinate of Area.
Definition: touch.h:77
+
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
+
void calculate_shadows(uint16_t bgcolor, uint16_t *light_shadow, uint16_t *dark_shadow)
Definition: button.c:34
+
void tft_fill_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:67
+
uint8_t font
The number of the font to use.
Definition: button.h:60
+

Here is the call graph for this function:
@@ -257,6 +344,14 @@ Here is the caller graph for this function:
+

Definition at line 184 of file button.c.

+
185 {
+
186  //We only need to unregister the touch area, as we have not allocated anything else
+ +
188 }
+
void touch_unregister_area(TOUCH_AREA_STRUCT *area)
Definition: touch.c:195
+ +

Here is the call graph for this function:
@@ -280,7 +375,7 @@ Here is the caller graph for this function:
diff --git a/group__calibrate.html b/group__calibrate.html index 4822736..d0cbf69 100644 --- a/group__calibrate.html +++ b/group__calibrate.html @@ -113,12 +113,18 @@ Functions

Returns a pointer to the calibrate screen

See also
gui_screen_navigate
Returns
+

Definition at line 118 of file screen_calibrate.c.

+
119 {
+
120  return &screen;
+
121 }
+
static SCREEN_STRUCT screen
+
diff --git a/group__checkbox.html b/group__checkbox.html index 5e3f3f2..2545bc2 100644 --- a/group__checkbox.html +++ b/group__checkbox.html @@ -132,6 +132,8 @@ Functions
+

Definition at line 82 of file checkbox.h.

+

Typedef Documentation

@@ -153,6 +155,8 @@ Functions +

Definition at line 45 of file checkbox.h.

+

Function Documentation

@@ -177,6 +181,56 @@ Functions
Returns
true on success
+

Definition at line 70 of file checkbox.c.

+
71 {
+
72  if (touch_have_empty(1)) { //Check if the touch module can handle one additional area
+
73  unsigned char size = 0;
+
74  checkbox->base.hookedActions = PEN_DOWN; //At first we are interested in PEN_DOWN events
+
75  checkbox->base.callback = checkboxes_cb; //Use our own callback for the touch area events
+
76 
+
77  //Check the size of the checkbox
+
78  if (checkbox->base.x2 > checkbox->base.x1) {
+
79  size = checkbox->base.x2 - checkbox->base.x1; //use width a as size
+
80  }
+
81 
+
82  if (checkbox->base.y2 > checkbox->base.y1) {
+
83  if ((checkbox->base.y2 - checkbox->base.y1) > size) { //height is larger than size
+
84  size = checkbox->base.y2 - checkbox->base.y1; //use height as size
+
85  }
+
86  }
+
87 
+
88  if (size == 0) { //no size found (maybe swap x2 and x1 or y2 and y1 ?)
+
89  return false; //signal error
+
90  }
+
91 
+
92  if ((size & 0x01)) { //the size is an odd number
+
93  size++; //make size an even number
+
94  }
+
95 
+
96  //Correct x2,y2 so that the checkbox is quadratic
+
97  checkbox->base.x2 = checkbox->base.x1 + size;
+
98  checkbox->base.y2 = checkbox->base.y1 + size;
+
99 
+
100  gui_checkbox_redraw(checkbox);//Call redraw method, which will take care of the drawing of the entire checkbox
+
101 
+
102  return touch_register_area(&checkbox->base); //Register the touch area and receive events for this checkbox, from now on
+
103  }
+
104 
+
105  return false; //no more touch areas left
+
106 }
+
bool touch_register_area(TOUCH_AREA_STRUCT *area)
Definition: touch.c:181
+
Receive an event when the pen goes down inside the region.
Definition: touch.h:54
+
uint16_t y1
Top Left Y-Coordinate of Area.
Definition: touch.h:75
+
uint16_t x1
Top Left X-Coordinate of Area.
Definition: touch.h:74
+
uint16_t y2
Bottom Right Y-Coordinate of Area.
Definition: touch.h:77
+
TOUCH_CALLBACK callback
Callback which is executed when an event occurred in this Area.
Definition: touch.h:78
+
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
+
TOUCH_ACTION hookedActions
Actions to listen to.
Definition: touch.h:73
+
TOUCH_AREA_STRUCT base
Basic geometry of the Checkbox. You only need to set the x1, y1, x2, y2 members of this struct...
Definition: checkbox.h:51
+
bool touch_have_empty(unsigned char num)
Definition: touch.c:165
+
void gui_checkbox_redraw(CHECKBOX_STRUCT *checkbox)
Definition: checkbox.c:108
+
void checkboxes_cb(void *touchArea, TOUCH_ACTION triggeredAction)
Definition: checkbox.c:34
+

Here is the call graph for this function:
@@ -217,6 +271,28 @@ Here is the caller graph for this function:
+

Definition at line 108 of file checkbox.c.

+
109 {
+
110  //Draw background and border
+
111  tft_fill_rectangle(checkbox->base.x1 + 1, checkbox->base.y1 + 1, checkbox->base.x2 - 1, checkbox->base.y2 - 1, BACKGROUND_COLOR);
+
112  tft_draw_rectangle(checkbox->base.x1, checkbox->base.y1, checkbox->base.x2, checkbox->base.y2, BORDER_COLOR);
+
113 
+
114  if (checkbox->checked) { //checkbox is currently checked
+
115  gui_checkbox_update(checkbox); //Call update method which will draw the tickmark
+
116  }
+
117 }
+
uint16_t y1
Top Left Y-Coordinate of Area.
Definition: touch.h:75
+
void gui_checkbox_update(CHECKBOX_STRUCT *checkbox)
Definition: checkbox.c:125
+
#define BACKGROUND_COLOR
Definition: checkbox.c:31
+
uint16_t x1
Top Left X-Coordinate of Area.
Definition: touch.h:74
+
bool checked
A boolean which indicates whether or not the checkbox is currently checked.
Definition: checkbox.h:53
+
uint16_t y2
Bottom Right Y-Coordinate of Area.
Definition: touch.h:77
+
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
+
void tft_fill_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:67
+
void tft_draw_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:61
+
#define BORDER_COLOR
Definition: checkbox.c:30
+
TOUCH_AREA_STRUCT base
Basic geometry of the Checkbox. You only need to set the x1, y1, x2, y2 members of this struct...
Definition: checkbox.h:51
+

Here is the call graph for this function:
@@ -257,6 +333,14 @@ Here is the caller graph for this function:
+

Definition at line 119 of file checkbox.c.

+
120 {
+
121  //We only need to unregister the touch area, as we have not allocated anything else
+ +
123 }
+
void touch_unregister_area(TOUCH_AREA_STRUCT *area)
Definition: touch.c:195
+ +

Here is the call graph for this function:
@@ -297,6 +381,35 @@ Here is the caller graph for this function:
+

Definition at line 125 of file checkbox.c.

+
126 {
+
127  unsigned int c = (checkbox->checked) ? checkbox->fgcolor : BACKGROUND_COLOR; //color to use for the tickmark
+
128 
+
129  //helper points inside the checkbox
+
130  unsigned int xcent = checkbox->base.x1 + (checkbox->base.x2 - checkbox->base.x1) * 6 / 14;
+
131  unsigned int yleft = checkbox->base.y2 - (xcent - checkbox->base.x1) - 1 ;
+
132  unsigned int yright = checkbox->base.y2 - (checkbox->base.x2 - xcent) - 1 ;
+
133  unsigned int ybot = checkbox->base.y2 - 4;
+
134 
+
135  //Draw tickmark as a 3pixel wide line
+
136  tft_draw_line(checkbox->base.x1 + 3, yleft - 1, xcent, ybot - 1, c);
+
137  tft_draw_line(checkbox->base.x1 + 3, yleft, xcent, ybot , c);
+
138  tft_draw_line(checkbox->base.x1 + 3, yleft + 1, xcent, ybot + 1, c);
+
139  xcent++;
+
140  ybot--;
+
141  tft_draw_line(xcent, ybot - 1, checkbox->base.x2 - 3, yright - 1, c);
+
142  tft_draw_line(xcent, ybot, checkbox->base.x2 - 3, yright + 0, c);
+
143  tft_draw_line(xcent, ybot + 1, checkbox->base.x2 - 3, yright + 1, c);
+
144 }
+
void tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:50
+
#define BACKGROUND_COLOR
Definition: checkbox.c:31
+
uint16_t x1
Top Left X-Coordinate of Area.
Definition: touch.h:74
+
bool checked
A boolean which indicates whether or not the checkbox is currently checked.
Definition: checkbox.h:53
+
uint16_t y2
Bottom Right Y-Coordinate of Area.
Definition: touch.h:77
+
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
+
TOUCH_AREA_STRUCT base
Basic geometry of the Checkbox. You only need to set the x1, y1, x2, y2 members of this struct...
Definition: checkbox.h:51
+
uint16_t fgcolor
The 16-bit color of the tickmark.
Definition: checkbox.h:52
+

Here is the call graph for this function:
@@ -320,7 +433,7 @@ Here is the caller graph for this function:
diff --git a/group__filesystem.html b/group__filesystem.html index 035382b..6a4b1e5 100644 --- a/group__filesystem.html +++ b/group__filesystem.html @@ -100,12 +100,12 @@ Data Structures

Enumerations

enum  FILE_ATTRIBUTES {
-  F_RDO =0x01, -F_HID =0x02, -F_SYS =0x04, -F_DIR =0x10, +  F_RDO = 0x01, +F_HID = 0x02, +F_SYS = 0x04, +F_DIR = 0x10,
-  F_ARC =0x20 +  F_ARC = 0x20
}   @@ -170,6 +170,21 @@ Functions +

Definition at line 32 of file filesystem.h.

+
32  {
+
33  F_RDO = 0x01,
+
34  F_HID = 0x02,
+
35  F_SYS = 0x04,
+
36  F_DIR = 0x10,
+
37  F_ARC = 0x20
+ +
File has the archive flag set (probably unused)
Definition: filesystem.h:37
+
File is a system file.
Definition: filesystem.h:35
+
File is hidden.
Definition: filesystem.h:34
+
It's a directory and not a file.
Definition: filesystem.h:36
+
FILE_ATTRIBUTES
Definition: filesystem.h:32
+
File is readonly. You cannot write to it.
Definition: filesystem.h:33
+
@@ -200,6 +215,21 @@ Functions +

Definition at line 90 of file filesystem.h.

+
90  {
+
91  F_OK,
+
92  F_EOF,
+
93  F_EACCESS,
+ + +
96 } FILE_STATUS;
+
The write/read operation tried to write/read past the end of the file. This is not a fatal error...
Definition: filesystem.h:92
+
You passed invalid parameters to the function.
Definition: filesystem.h:94
+
A lowlevel disk-error occoured. This is a fatal error.
Definition: filesystem.h:95
+
Everything ok.
Definition: filesystem.h:91
+
The file can not be read/written due to access problems. This is a fatal error.
Definition: filesystem.h:93
+
FILE_STATUS
Definition: filesystem.h:90
+

Function Documentation

@@ -223,6 +253,12 @@ Functions +

Definition at line 28 of file filesystem.c.

+
29 {
+ +
31 }
+
void ll_filesystem_dir_close(DIRECTORY_STRUCT *dir)
+

Here is the call graph for this function:
@@ -265,6 +301,12 @@ Here is the caller graph for this function:
Returns
A Pointer to an initialized DIRECTORY_STRUCT on success, NULL on error
+

Definition at line 23 of file filesystem.c.

+
24 {
+
25  return ll_filesystem_dir_open(path);
+
26 }
+
DIRECTORY_STRUCT * ll_filesystem_dir_open(const char *path)
+

Here is the call graph for this function:
@@ -305,6 +347,12 @@ Here is the caller graph for this function:
+

Definition at line 38 of file filesystem.c.

+
39 {
+ +
41 }
+
void ll_filesystem_file_close(FILE_HANDLE *handle)
+

Here is the call graph for this function:
@@ -347,6 +395,12 @@ Here is the caller graph for this function:
Returns
A Pointer to a FILE_HANDLE on success, NULL on error.
+

Definition at line 33 of file filesystem.c.

+
34 {
+
35  return ll_filesystem_file_open(filename);
+
36 }
+
FILE_HANDLE * ll_filesystem_file_open(const char *filename)
+

Here is the call graph for this function:
@@ -406,6 +460,12 @@ Here is the caller graph for this function:
Returns
F_OK on success, F_EOF if less than size bytes could be read, an error Code otherwise.
+

Definition at line 48 of file filesystem.c.

+
49 {
+
50  return ll_filesystem_file_read(handle, buf, size);
+
51 }
+
FILE_STATUS ll_filesystem_file_read(FILE_HANDLE *handle, uint8_t *buf, uint32_t size)
+

Here is the call graph for this function:
@@ -458,6 +518,12 @@ Here is the caller graph for this function:
Returns
F_OK on success, an error Code otherwise.
+

Definition at line 43 of file filesystem.c.

+
44 {
+
45  return ll_filesystem_file_seek(handle, offset);
+
46 }
+
FILE_STATUS ll_filesystem_file_seek(FILE_HANDLE *handle, uint32_t offset)
+

Here is the call graph for this function:
@@ -518,6 +584,12 @@ Here is the caller graph for this function:
Returns
F_OK on success, F_EOF if less than size bytes could be written, an error Code otherwise.
+

Definition at line 53 of file filesystem.c.

+
54 {
+
55  return ll_filesystem_file_write(handle, buf, size);
+
56 }
+
FILE_STATUS ll_filesystem_file_write(FILE_HANDLE *handle, uint8_t *buf, uint32_t size)
+

Here is the call graph for this function:
@@ -552,6 +624,12 @@ Here is the caller graph for this function:

Initializes the filesystem. Call this method before using any filesystem_* functions

Returns
true on success
+

Definition at line 18 of file filesystem.c.

+
19 {
+
20  return ll_filesystem_init();
+
21 }
+
bool ll_filesystem_init()
+

Here is the call graph for this function:
@@ -575,7 +653,7 @@ Here is the caller graph for this function:
diff --git a/group__filetest.html b/group__filetest.html index c7b361d..cdebcfa 100644 --- a/group__filetest.html +++ b/group__filetest.html @@ -113,6 +113,12 @@ Functions

Returns a pointer to the filetest screen

See also
gui_screen_navigate
Returns
+

Definition at line 141 of file screen_filetest.c.

+
142 {
+
143  return &screen;
+
144 }
+
static SCREEN_STRUCT screen
+

Here is the caller graph for this function:
@@ -127,7 +133,7 @@ Here is the caller graph for this function:
diff --git a/group__gui.html b/group__gui.html index 771498a..7b5a695 100644 --- a/group__gui.html +++ b/group__gui.html @@ -106,7 +106,7 @@ Modules diff --git a/group__guitest.html b/group__guitest.html index b44ac27..3f854d5 100644 --- a/group__guitest.html +++ b/group__guitest.html @@ -113,6 +113,12 @@ Functions

Returns a pointer to the guitest screen

See also
gui_screen_navigate
Returns
+

Definition at line 161 of file screen_guitest.c.

+
162 {
+
163  return &screen;
+
164 }
+
static SCREEN_STRUCT screen
+

Here is the caller graph for this function:
@@ -127,7 +133,7 @@ Here is the caller graph for this function:
diff --git a/group__ll__filesystem.html b/group__ll__filesystem.html index 7d0baac..5d3c8c9 100644 --- a/group__ll__filesystem.html +++ b/group__ll__filesystem.html @@ -356,7 +356,7 @@ Here is the caller graph for this function: diff --git a/group__ll__system.html b/group__ll__system.html index 1c7cdca..04bdb66 100644 --- a/group__ll__system.html +++ b/group__ll__system.html @@ -204,7 +204,7 @@ Here is the caller graph for this function: diff --git a/group__ll__tft.html b/group__ll__tft.html index ce43ee3..6ecb7af 100644 --- a/group__ll__tft.html +++ b/group__ll__tft.html @@ -605,7 +605,7 @@ Here is the caller graph for this function: diff --git a/group__ll__touch.html b/group__ll__touch.html index 0a643d1..4669f09 100644 --- a/group__ll__touch.html +++ b/group__ll__touch.html @@ -125,7 +125,7 @@ Here is the caller graph for this function: diff --git a/group__lowlevel.html b/group__lowlevel.html index 7b2bcdd..bd4d2a0 100644 --- a/group__lowlevel.html +++ b/group__lowlevel.html @@ -106,7 +106,7 @@ Modules diff --git a/group__main.html b/group__main.html index b60e50b..39038fa 100644 --- a/group__main.html +++ b/group__main.html @@ -113,6 +113,12 @@ Functions

Returns a pointer to the main screen

See also
gui_screen_navigate
Returns
+

Definition at line 196 of file screen_main.c.

+
197 {
+
198  return &screen;
+
199 }
+
static SCREEN_STRUCT screen
Definition: screen_main.c:189
+

Here is the caller graph for this function:
@@ -127,7 +133,7 @@ Here is the caller graph for this function:
diff --git a/group__numupdown.html b/group__numupdown.html index d749c6d..413f02a 100644 --- a/group__numupdown.html +++ b/group__numupdown.html @@ -134,6 +134,8 @@ Functions +

Definition at line 43 of file numupdown.h.

+

Function Documentation

@@ -158,6 +160,93 @@ Functions
Returns
true on success
+

Definition at line 80 of file numupdown.c.

+
81 {
+
82  if (touch_have_empty(2)) { //Check if the touch module can handle two additional areas
+
83  if (numupdown->min > numupdown->max) { //min is bigger than max?
+
84  return false; //invalid parameter
+
85  }
+
86 
+
87  if (numupdown->value < numupdown->min) { //value is smaller than min?
+
88  numupdown->value = numupdown->min; //normalize value
+
89  } else if (numupdown->value > numupdown->max) { //value is bigger than max?
+
90  numupdown->value = numupdown->max; //normalize value
+
91  }
+
92 
+
93  uint8_t tw1 = calc_text_width(numupdown->max); //Calculate character width to render maximum value
+
94  uint8_t tw2 = calc_text_width(numupdown->min); //Calculate character width to render minimum value
+
95 
+
96  if (tw2 > tw1) {
+
97  tw1 = tw2; //ensure tw1 contains the larger number of the two
+
98  }
+
99 
+
100  uint8_t width = tft_font_width(0) * (tw1 + 1); //Calculate width of the number area
+
101 
+
102  //Add "minus" button to the left side of the number area
+
103  numupdown->buttonDown.base.x1 = numupdown->x;
+
104  numupdown->buttonDown.base.y1 = numupdown->y;
+
105  numupdown->buttonDown.base.x2 = AUTO;
+
106  numupdown->buttonDown.base.y2 = numupdown->y + tft_font_height(0) * 2;
+
107  numupdown->buttonDown.text = "-";
+
108  numupdown->buttonDown.font = 0;
+
109  numupdown->buttonDown.bgcolor = BASE_COLOR;
+
110  numupdown->buttonDown.txtcolor = WHITE;
+
111  numupdown->buttonDown.callback = button_down_cb;
+
112  gui_button_add(&numupdown->buttonDown);
+
113 
+
114  //Add "plus" button to the right side of the number area
+
115  numupdown->buttonUp.base.x1 = numupdown->buttonDown.base.x2 + width + 2;
+
116  numupdown->buttonUp.base.y1 = numupdown->y;
+
117  numupdown->buttonUp.base.x2 = AUTO;
+
118  numupdown->buttonUp.base.y2 = numupdown->y + tft_font_height(0) * 2;
+
119  numupdown->buttonUp.text = "+";
+
120  numupdown->buttonUp.font = 0;
+
121  numupdown->buttonUp.bgcolor = BASE_COLOR;
+
122  numupdown->buttonUp.txtcolor = WHITE;
+
123  numupdown->buttonUp.callback = button_up_cb;
+
124  gui_button_add(&numupdown->buttonUp);
+
125 
+
126  //Draw background and label of the number area
+
127  tft_fill_rectangle(numupdown->buttonDown.base.x2 + 2, numupdown->y, numupdown->buttonDown.base.x2 + width, numupdown->buttonUp.base.y2, BASE_COLOR);
+
128  tft_print_formatted(numupdown->buttonDown.base.x2 + 2 + tft_font_width(0) / 2, numupdown->y + tft_font_height(0) / 2, numupdown->fgcolor, BASE_COLOR, 0, "%*d", tw1, numupdown->value);
+
129 
+
130  return true;
+
131  }
+
132 
+
133  return false; //not enough touch areas left
+
134 }
+
uint8_t tft_font_height(uint8_t fontnum)
Definition: tft.c:87
+
const char * text
The label of the button.
Definition: button.h:61
+
uint8_t tft_font_width(uint8_t fontnum)
Definition: tft.c:92
+
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
+
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
+
void tft_print_formatted(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, const char *format,...)
Definition: tft.c:111
+
bool gui_button_add(BUTTON_STRUCT *button)
Definition: button.c:133
+
uint16_t x1
Top Left X-Coordinate of Area.
Definition: touch.h:74
+
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
+
uint16_t y2
Bottom Right Y-Coordinate of Area.
Definition: touch.h:77
+
void button_down_cb(void *button)
Definition: numupdown.c:50
+
static uint8_t calc_text_width(int16_t val)
Definition: numupdown.c:66
+
uint16_t y
The y-Coordinate of the Top-Left Starting Point.
Definition: numupdown.h:50
+
int16_t max
The maximum possible value (inclusive)
Definition: numupdown.h:54
+
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
+
int16_t min
The minimum possible value (inclusive)
Definition: numupdown.h:53
+
#define WHITE
Definition: tft.h:53
+
void tft_fill_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:67
+
uint16_t width
Definition: pixy.h:82
+
uint16_t fgcolor
The 16-bit color of the value-text.
Definition: numupdown.h:51
+
BUTTON_STRUCT buttonDown
For internal use, don't change, don't initialize.
Definition: numupdown.h:58
+
void button_up_cb(void *button)
Definition: numupdown.c:34
+
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
+
bool touch_have_empty(unsigned char num)
Definition: touch.c:165
+
uint8_t font
The number of the font to use.
Definition: button.h:60
+
#define BASE_COLOR
Definition: numupdown.c:31
+
BUTTON_STRUCT buttonUp
For internal use, don't change, don't initialize.
Definition: numupdown.h:57
+

Here is the call graph for this function:
@@ -198,6 +287,20 @@ Here is the caller graph for this function:
+

Definition at line 144 of file numupdown.c.

+
145 {
+
146  //redraw the two buttons
+
147  gui_button_redraw(&numupdown->buttonUp);
+
148  gui_button_redraw(&numupdown->buttonDown);
+
149 
+
150  //call update method which will take care of the number-area rendering
+
151  gui_numupdown_update(numupdown);
+
152 }
+
void gui_button_redraw(BUTTON_STRUCT *button)
Definition: button.c:164
+
BUTTON_STRUCT buttonDown
For internal use, don't change, don't initialize.
Definition: numupdown.h:58
+
void gui_numupdown_update(NUMUPDOWN_STRUCT *numupdown)
Definition: numupdown.c:154
+
BUTTON_STRUCT buttonUp
For internal use, don't change, don't initialize.
Definition: numupdown.h:57
+

Here is the call graph for this function:
@@ -229,6 +332,16 @@ Here is the call graph for this function:
+

Definition at line 136 of file numupdown.c.

+
137 {
+
138  //remove the two buttons, we have no other allocated resources
+
139  gui_button_remove(&numupdown->buttonUp);
+
140  gui_button_remove(&numupdown->buttonDown);
+
141 }
+
void gui_button_remove(BUTTON_STRUCT *button)
Definition: button.c:184
+
BUTTON_STRUCT buttonDown
For internal use, don't change, don't initialize.
Definition: numupdown.h:58
+
BUTTON_STRUCT buttonUp
For internal use, don't change, don't initialize.
Definition: numupdown.h:57
+

Here is the call graph for this function:
@@ -269,6 +382,40 @@ Here is the caller graph for this function:
+

Definition at line 154 of file numupdown.c.

+
155 {
+
156  //Calculate the number area width again (see above)
+
157  uint8_t tw1 = calc_text_width(numupdown->max);
+
158  uint8_t tw2 = calc_text_width(numupdown->min);
+
159 
+
160  if (tw2 > tw1) {
+
161  tw1 = tw2;
+
162  }
+
163 
+
164  uint8_t width = tft_font_width(0) * (tw1 + 1);
+
165 
+
166  //Draw background and label of the number area
+
167  tft_fill_rectangle(numupdown->buttonDown.base.x2 + 2, numupdown->y, numupdown->buttonDown.base.x2 + width, numupdown->buttonUp.base.y2, BASE_COLOR);
+
168  tft_print_formatted(numupdown->buttonDown.base.x2 + 2 + tft_font_width(0) / 2, numupdown->y + tft_font_height(0) / 2, numupdown->fgcolor, BASE_COLOR, 0, "%*d", tw1, numupdown->value);
+
169 }
+
uint8_t tft_font_height(uint8_t fontnum)
Definition: tft.c:87
+
uint8_t tft_font_width(uint8_t fontnum)
Definition: tft.c:92
+
void tft_print_formatted(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, const char *format,...)
Definition: tft.c:111
+
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
+
uint16_t y2
Bottom Right Y-Coordinate of Area.
Definition: touch.h:77
+
static uint8_t calc_text_width(int16_t val)
Definition: numupdown.c:66
+
uint16_t y
The y-Coordinate of the Top-Left Starting Point.
Definition: numupdown.h:50
+
int16_t max
The maximum possible value (inclusive)
Definition: numupdown.h:54
+
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
+
int16_t min
The minimum possible value (inclusive)
Definition: numupdown.h:53
+
void tft_fill_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:67
+
uint16_t width
Definition: pixy.h:82
+
uint16_t fgcolor
The 16-bit color of the value-text.
Definition: numupdown.h:51
+
BUTTON_STRUCT buttonDown
For internal use, don't change, don't initialize.
Definition: numupdown.h:58
+
int16_t value
The current/default value.
Definition: numupdown.h:52
+
#define BASE_COLOR
Definition: numupdown.c:31
+
BUTTON_STRUCT buttonUp
For internal use, don't change, don't initialize.
Definition: numupdown.h:57
+

Here is the call graph for this function:
@@ -292,7 +439,7 @@ Here is the caller graph for this function:
diff --git a/group__photomode.html b/group__photomode.html index 4eedc41..da5213a 100644 --- a/group__photomode.html +++ b/group__photomode.html @@ -113,6 +113,12 @@ Functions

Returns a pointer to the photomode screen

See also
gui_screen_navigate
Returns
+

Definition at line 205 of file screen_photomode.c.

+
206 {
+
207  return &screen;
+
208 }
+
static SCREEN_STRUCT screen
+

Here is the caller graph for this function:
@@ -127,7 +133,7 @@ Here is the caller graph for this function:
diff --git a/group__photomodesave.html b/group__photomodesave.html index bdad010..22fdd62 100644 --- a/group__photomodesave.html +++ b/group__photomodesave.html @@ -113,6 +113,12 @@ Functions

Returns a pointer to the photomode save screen

See also
gui_screen_navigate
Returns
+

Definition at line 338 of file screen_photomode_save.c.

+
339 {
+
340  return &screen;
+
341 }
+
static SCREEN_STRUCT screen
+

Here is the caller graph for this function:
@@ -127,7 +133,7 @@ Here is the caller graph for this function:
diff --git a/group__pixy.html b/group__pixy.html index cc35c79..19ec82f 100644 --- a/group__pixy.html +++ b/group__pixy.html @@ -199,6 +199,8 @@ Functions
+

Definition at line 51 of file pixy.h.

+
@@ -211,6 +213,8 @@ Functions
+

Definition at line 50 of file pixy.h.

+
@@ -223,6 +227,8 @@ Functions
+

Definition at line 36 of file pixy.h.

+
@@ -235,6 +241,8 @@ Functions
+

Definition at line 40 of file pixy.h.

+
@@ -247,6 +255,8 @@ Functions
+

Definition at line 42 of file pixy.h.

+
@@ -259,6 +269,8 @@ Functions
+

Definition at line 39 of file pixy.h.

+
@@ -271,6 +283,8 @@ Functions
+

Definition at line 41 of file pixy.h.

+
@@ -283,6 +297,8 @@ Functions
+

Definition at line 47 of file pixy.h.

+
@@ -295,6 +311,8 @@ Functions
+

Definition at line 46 of file pixy.h.

+
@@ -307,6 +325,8 @@ Functions
+

Definition at line 45 of file pixy.h.

+

Function Documentation

@@ -1087,7 +1107,7 @@ Here is the caller graph for this function: diff --git a/group__pixy__control.html b/group__pixy__control.html index ce9af0b..8e89dbf 100644 --- a/group__pixy__control.html +++ b/group__pixy__control.html @@ -132,6 +132,34 @@ Functions
Returns
The offset which needs to be added to the X-Servo position
+

Definition at line 67 of file pixy_control.c.

+
68 {
+
69  float e = 0;
+
70  static float esum = 0;
+
71  static float eold = 0;
+
72  float y = 0;
+
73 
+
74  e = (float)(x - w); // calculate the controller offset
+
75 
+
76  //----PID-control-------------------------------------------------------------------------
+
77  esum = esum + e; // add e to the current sum
+
78 
+
79  y += REG_PID_KP * e; // add the proportional part to the output
+
80  y += REG_PID_KI * REG_PID_TA * esum; // add the integral part to the output
+
81  y += REG_PID_KD * (e - eold) / REG_PID_TA; // add the differential part to the output
+
82  //----------------------------------------------------------------------------------------
+
83 
+
84  eold = e; // save the previous value
+
85 
+
86  return (int16_t)y;
+
87 }
+
#define REG_PID_KI
Definition: pixy_control.c:38
+
#define REG_PID_KP
Definition: pixy_control.c:37
+
#define REG_PID_TA
Definition: pixy_control.c:40
+
uint16_t y
Definition: pixy.h:81
+
uint16_t x
Definition: pixy.h:80
+
#define REG_PID_KD
Definition: pixy_control.c:39
+

Here is the caller graph for this function:
@@ -175,6 +203,34 @@ Here is the caller graph for this function:
Returns
The offset which needs to be added to the Y-Servo position
+

Definition at line 44 of file pixy_control.c.

+
45 {
+
46  float e = 0;
+
47  static float esum = 0;
+
48  static float eold = 0;
+
49  float y = 0;
+
50 
+
51  e = (float)(x - w); // calculate the controller offset
+
52 
+
53  //----PID-control-------------------------------------------------------------------------
+
54  esum = esum + e; // add e to the current sum
+
55 
+
56  y += REG_PID_KP * e; // add the proportional part to the output
+
57  y += REG_PID_KI * REG_PID_TA * esum; // add the integral part to the output
+
58  y += REG_PID_KD * (e - eold) / REG_PID_TA; // add the differential part to the output
+
59  //----------------------------------------------------------------------------------------
+
60 
+
61  eold = e; // save the previous value
+
62 
+
63  return (int16_t)y;
+
64 }
+
#define REG_PID_KI
Definition: pixy_control.c:38
+
#define REG_PID_KP
Definition: pixy_control.c:37
+
#define REG_PID_TA
Definition: pixy_control.c:40
+
uint16_t y
Definition: pixy.h:81
+
uint16_t x
Definition: pixy.h:80
+
#define REG_PID_KD
Definition: pixy_control.c:39
+

Here is the caller graph for this function:
@@ -189,7 +245,7 @@ Here is the caller graph for this function:
diff --git a/group__pixy__helper.html b/group__pixy__helper.html index 9acbd92..17df325 100644 --- a/group__pixy__helper.html +++ b/group__pixy__helper.html @@ -159,6 +159,31 @@ Functions
Returns
0 on success, otherwise the errorcode from pixy
+

Definition at line 233 of file pixy_frame.c.

+
234 {
+
235  int32_t response;
+
236 
+
237  int return_value = pixy_command("cc_setSigRegion", // String id for remote procedure
+
238  INT32(0), // type = normal color code
+
239  INT8(signum),
+
240  INT16(xoffset), // xoffset
+
241  INT16(yoffset), // yoffset
+
242  INT16(width), // width
+
243  INT16(height), // height
+
244  END_OUT_ARGS, // separator
+
245  &response, // pointer to mem address for return value
+
246  END_IN_ARGS);
+
247  return return_value;
+
248 }
+
#define INT16(v)
Definition: pixydefs.h:63
+
#define INT32(v)
Definition: pixydefs.h:65
+
int pixy_command(const char *name,...)
Send a command to Pixy.
+
uint16_t height
Definition: pixy.h:83
+
uint16_t width
Definition: pixy.h:82
+
#define END_OUT_ARGS
Definition: pixydefs.h:89
+
#define END_IN_ARGS
Definition: pixydefs.h:90
+
#define INT8(v)
Definition: pixydefs.h:61
+

Here is the call graph for this function:
@@ -239,6 +264,50 @@ Here is the caller graph for this function:
Returns
0 on success, otherwise the errorcode from pixy
+

Definition at line 31 of file pixy_frame.c.

+
32 {
+
33  uint8_t* videodata;
+
34  int32_t response;
+
35  int32_t fourccc;
+
36  int8_t renderflags;
+
37  uint16_t xwidth;
+
38  uint16_t ywidth;
+
39  uint32_t size;
+
40 
+
41 
+
42  int return_value = pixy_command("cam_getFrame", // String id for remote procedure
+
43  INT8(0x21), // mode
+
44  INT16(xoffset), // xoffset
+
45  INT16(yoffset), // yoffset
+
46  INT16(width), // width
+
47  INT16(height), // height
+
48  END_OUT_ARGS, // separator
+
49  &response, // pointer to mem address for return value
+
50  &fourccc,
+
51  &renderflags,
+
52  &xwidth,
+
53  &ywidth,
+
54  &size,
+
55  &videodata, // pointer to mem address for returned frame
+
56  END_IN_ARGS);
+
57 
+
58  if (return_value == 0) {
+
59  return_value = renderBA81(x, y, xwidth, ywidth, size, videodata);
+
60  }
+
61 
+
62  return return_value;
+
63 }
+
static int renderBA81(uint16_t xpos, uint16_t ypos, uint16_t width, uint16_t height, uint32_t frameLen, uint8_t *frame)
Definition: pixy_frame.c:139
+
#define INT16(v)
Definition: pixydefs.h:63
+
uint16_t y
Definition: pixy.h:81
+
int pixy_command(const char *name,...)
Send a command to Pixy.
+
uint16_t height
Definition: pixy.h:83
+
uint16_t width
Definition: pixy.h:82
+
#define END_OUT_ARGS
Definition: pixydefs.h:89
+
uint16_t x
Definition: pixy.h:80
+
#define END_IN_ARGS
Definition: pixydefs.h:90
+
#define INT8(v)
Definition: pixydefs.h:61
+

Here is the call graph for this function:
@@ -291,6 +360,14 @@ Here is the caller graph for this function:
Returns
0 on success, otherwise the errorcode from pixy
+

Definition at line 25 of file pixy_frame.c.

+
26 {
+
27  return pixy_render_cropped_frame(x, y, 0, 0, 320, 200);
+
28 }
+
uint16_t y
Definition: pixy.h:81
+
int pixy_render_cropped_frame(uint16_t x, uint16_t y, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
Definition: pixy_frame.c:31
+
uint16_t x
Definition: pixy.h:80
+

Here is the call graph for this function:
@@ -364,6 +441,48 @@ Here is the caller graph for this function:
Returns
0 on success, otherwise the errorcode from pixy
+

Definition at line 70 of file pixy_frame.c.

+
71 {
+
72  uint8_t* videodata;
+
73  int32_t response;
+
74  int32_t fourccc;
+
75  int8_t renderflags;
+
76  uint16_t xwidth;
+
77  uint16_t ywidth;
+
78  uint32_t size;
+
79 
+
80 
+
81  int return_value = pixy_command("cam_getFrame", // String id for remote procedure
+
82  INT8(0x21), // mode
+
83  INT16(xoffset), // xoffset
+
84  INT16(yoffset), // yoffset
+
85  INT16(width), // width
+
86  INT16(height), // height
+
87  END_OUT_ARGS, // separator
+
88  &response, // pointer to mem address for return value
+
89  &fourccc,
+
90  &renderflags,
+
91  &xwidth,
+
92  &ywidth,
+
93  &size,
+
94  &videodata, // pointer to mem address for returned frame
+
95  END_IN_ARGS);
+
96 
+
97  if (return_value == 0) {
+
98  return_value = saveBA81(handle, xwidth, ywidth, size, videodata);
+
99  }
+
100 
+
101  return return_value;
+
102 }
+
static int saveBA81(FILE_HANDLE *handle, uint16_t width, uint16_t height, uint32_t frameLen, uint8_t *frame)
Definition: pixy_frame.c:189
+
#define INT16(v)
Definition: pixydefs.h:63
+
int pixy_command(const char *name,...)
Send a command to Pixy.
+
uint16_t height
Definition: pixy.h:83
+
uint16_t width
Definition: pixy.h:82
+
#define END_OUT_ARGS
Definition: pixydefs.h:89
+
#define END_IN_ARGS
Definition: pixydefs.h:90
+
#define INT8(v)
Definition: pixydefs.h:61
+

Here is the call graph for this function:
@@ -405,6 +524,12 @@ Here is the caller graph for this function:
Returns
0 on success, otherwise the errorcode from pixy
+

Definition at line 65 of file pixy_frame.c.

+
66 {
+
67  return pixy_save_cropped_frame(handle, 0, 0, 320, 200);
+
68 }
+
int pixy_save_cropped_frame(FILE_HANDLE *handle, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
Definition: pixy_frame.c:70
+

Here is the call graph for this function:
@@ -428,7 +553,7 @@ Here is the caller graph for this function:
diff --git a/group__pixytest.html b/group__pixytest.html index 55a271b..5c6e220 100644 --- a/group__pixytest.html +++ b/group__pixytest.html @@ -113,6 +113,12 @@ Functions

Returns a pointer to the pixytest screen

See also
gui_screen_navigate
Returns
+

Definition at line 374 of file screen_pixytest.c.

+
375 {
+
376  return &screen;
+
377 }
+
static SCREEN_STRUCT screen
+

Here is the caller graph for this function:
@@ -127,7 +133,7 @@ Here is the caller graph for this function:
diff --git a/group__screen.html b/group__screen.html index b27b0be..c0128f1 100644 --- a/group__screen.html +++ b/group__screen.html @@ -134,6 +134,8 @@ Functions +

Definition at line 47 of file screen.h.

+ @@ -164,6 +166,38 @@ Functions

Navigate one screen back as soon as the app enters the main loop again. It's safe to call this method from an interrupt

Returns
true on success
+

Definition at line 85 of file screen.c.

+
86 {
+
87  if (screen_list == NULL) { //the list head is emtpy, nothing to go back to
+
88  return false;
+
89  }
+
90 
+
91  SCREEN_STRUCT* current = screen_list;
+
92  SCREEN_STRUCT* last = NULL;
+
93 
+
94  //Find second last element in list
+
95  while (current->next != NULL) {
+
96  last = current;
+
97  current = current->next;
+
98  }
+
99 
+
100  if (last == NULL) {
+
101  return false; //There's only a single screen, there's no going back here
+
102  }
+
103 
+
104  if (current != screen_current) {
+
105  return false; //The last entry in the list is not the current screen. List corrupted?
+
106  }
+
107 
+
108  screen_goto = last; //"send message" to main loop, to switch the screen
+
109  return true;
+
110 }
+
struct SCREEN_S * next
Used internally. do not modify, do not initialize.
Definition: screen.h:57
+
static SCREEN_STRUCT * screen_current
Definition: screen.c:32
+
static volatile SCREEN_STRUCT * screen_goto
Definition: screen.c:33
+
static SCREEN_STRUCT * screen_list
Definition: screen.c:31
+ +

Here is the caller graph for this function:
@@ -189,6 +223,12 @@ Here is the caller graph for this function:

Returns the currently active screen

Returns
A Pointer to the active SCREEN_STRUCT
+

Definition at line 35 of file screen.c.

+
36 {
+
37  return screen_current;
+
38 }
+
static SCREEN_STRUCT * screen_current
Definition: screen.c:32
+
@@ -213,6 +253,21 @@ Here is the caller graph for this function:
Returns
true on success
+

Definition at line 74 of file screen.c.

+
75 {
+
76  if (screen == NULL || screen == screen_current || screen == screen_goto) { //invalid argument passed
+
77  return false;
+
78  }
+
79 
+
80  screen->next = NULL; //this will become the new tail of the list, so the next pointer must be NULL
+
81  screen_goto = screen; //"send message" to main loop, to switch the screen
+
82  return true;
+
83 }
+
struct SCREEN_S * next
Used internally. do not modify, do not initialize.
Definition: screen.h:57
+
static SCREEN_STRUCT * screen_current
Definition: screen.c:32
+
static volatile SCREEN_STRUCT * screen_goto
Definition: screen.c:33
+
static SCREEN_STRUCT screen
+

Here is the caller graph for this function:
@@ -238,6 +293,45 @@ Here is the caller graph for this function:

Updates the current screen. Switches the screen if gui_screen_navigate() or gui_screen_back() have been called since the last call to this method. This method should be called repeatedly from the main loop (e.g. app_process())

+

Definition at line 41 of file screen.c.

+
42 {
+
43  if (screen_goto != NULL) { //we received the task to switch the screen
+
44  SCREEN_STRUCT* go = (SCREEN_STRUCT*) screen_goto; //Backup volatile variable
+
45  screen_goto = NULL; //reset the "goto instruction", since we're processing it now
+
46 
+
47  if (go->next != NULL) { //The screen is not the last in the list, so we're going back
+
48  if (go->next != screen_current) { //this condition should always be false
+
49  return; //list corrupted?
+
50  }
+
51 
+
52  screen_current->on_leave(screen_current); //let the current screen free/unregister it's resources
+
53  go->next = NULL; //remove the current screen from the list
+
54  } else { //we're going forward (to a new screen)
+
55  if (screen_current != NULL) { //this is not the first screen
+
56  screen_current->on_leave(screen_current); //let the current screen free/unregister it's resources
+
57  screen_current->next = go; //append the new screen to the end of the list
+
58  } else { //first screen ever seen
+
59  screen_list = go; //set the new screen as list-head
+
60  }
+
61  }
+
62 
+
63  go->on_enter(go); //let the new screen allocate/register it's resources
+
64  screen_current = go; //the new screen is now the current screen. Transition done
+
65  }
+
66 
+
67  if (screen_current != NULL) { //A screen has been set
+
68  screen_current->on_update(screen_current); //Update current screen
+
69  }
+
70 }
+
SCREEN_CALLBACK on_enter
The Callback which is called when the screen is entered. Add/Register all UI-Elements here...
Definition: screen.h:53
+
struct SCREEN_S * next
Used internally. do not modify, do not initialize.
Definition: screen.h:57
+
static SCREEN_STRUCT * screen_current
Definition: screen.c:32
+
static volatile SCREEN_STRUCT * screen_goto
Definition: screen.c:33
+
static SCREEN_STRUCT * screen_list
Definition: screen.c:31
+
SCREEN_CALLBACK on_leave
The Callback which is called when the screen is left. Remove/Unregister all UI-Elements here...
Definition: screen.h:54
+ +
SCREEN_CALLBACK on_update
The Callback which is called repeatedly when the screen should be updated. Update/Redraw all UI-Eleme...
Definition: screen.h:55
+

Here is the caller graph for this function:
@@ -252,7 +346,7 @@ Here is the caller graph for this function:
diff --git a/group__screens.html b/group__screens.html index 83f92b8..f51b06f 100644 --- a/group__screens.html +++ b/group__screens.html @@ -112,7 +112,7 @@ Modules diff --git a/group__system.html b/group__system.html index 01638a7..be56a4e 100644 --- a/group__system.html +++ b/group__system.html @@ -116,6 +116,12 @@ Functions +

Definition at line 26 of file system.c.

+
27 {
+
28  ll_system_delay(msec);
+
29 }
+
void ll_system_delay(uint32_t msec)
+

Here is the call graph for this function:
@@ -141,6 +147,12 @@ Here is the call graph for this function:

Initializes the system. Call this method at the start of your app_init() function and before using any system_* functions

Returns
true on success
+

Definition at line 21 of file system.c.

+
22 {
+
23  return ll_system_init();
+
24 }
+
bool ll_system_init()
+

Here is the call graph for this function:
@@ -175,6 +187,12 @@ Here is the caller graph for this function:

Executes pending system events (like handling usb, timers etc). Call this somewhere in app_process().

+

Definition at line 31 of file system.c.

+
32 {
+ +
34 }
+
void ll_system_process()
+

Here is the call graph for this function:
@@ -209,6 +227,12 @@ Here is the caller graph for this function:

Toggles a Status Led. Use this function for debugging or to show activity

+

Definition at line 36 of file system.c.

+
37 {
+ +
39 }
+
void ll_system_toggle_led()
+

Here is the call graph for this function:
@@ -223,7 +247,7 @@ Here is the call graph for this function:
diff --git a/group__tft.html b/group__tft.html index 655f2c4..6c3fac6 100644 --- a/group__tft.html +++ b/group__tft.html @@ -146,6 +146,8 @@ Functions
+

Definition at line 54 of file tft.h.

+
@@ -158,6 +160,8 @@ Functions
+

Definition at line 52 of file tft.h.

+
@@ -170,6 +174,8 @@ Functions
+

Definition at line 51 of file tft.h.

+
@@ -187,6 +193,8 @@ Functions

Creates a 16bit color from a 24bit hex rgb color code

Returns
+

Definition at line 60 of file tft.h.

+
@@ -199,6 +207,8 @@ Functions
+

Definition at line 50 of file tft.h.

+
@@ -232,6 +242,8 @@ Functions

Creates a 16bit color from 8bit * 3 colors (r,g,b)

Returns
+

Definition at line 48 of file tft.h.

+
@@ -245,6 +257,8 @@ Functions

Transparent color

Returns
+

Definition at line 66 of file tft.h.

+
@@ -257,6 +271,8 @@ Functions
+

Definition at line 53 of file tft.h.

+

Function Documentation

@@ -280,6 +296,12 @@ Functions +

Definition at line 45 of file tft.c.

+
46 {
+
47  ll_tft_clear(color);
+
48 }
+
void ll_tft_clear(uint16_t color)
+

Here is the call graph for this function:
@@ -339,6 +361,80 @@ Here is the caller graph for this function:
Returns
true on success
+

Definition at line 123 of file tft.c.

+
124 {
+
125  //This method reads a .bmp file from the filesystem and tries to draw it.
+
126  //Note: The bmp implementation is not complete, it has some limitations and it makes assumptions. See doxygen comment for this method.
+
127  //Source Copied and adapted from: http://stackoverflow.com/a/17040962/2606757
+
128 
+
129  FILE_HANDLE* file = filesystem_file_open(filename); //try to open the file
+
130 
+
131  if (file == NULL) { //file opening failed
+
132  return false;
+
133  }
+
134 
+
135  unsigned char info[54];
+
136 
+
137  if (filesystem_file_read(file, info, 54) != F_OK) { //try to read the 54 byte header
+
138  filesystem_file_close(file);
+
139  return false; //reading the header failed
+
140  }
+
141 
+
142  // extract image height and width from header
+
143  uint32_t width = *(uint32_t*)&info[18]; //width in pixel
+
144  uint32_t height = *(uint32_t*)&info[22]; //height in pixel
+
145  uint16_t depth = *(uint16_t*)&info[28]; //bit's per pixel (color depth)
+
146  depth /= 8; //we want the number of bytes per pixel
+
147 
+
148  filesystem_file_seek(file, *(uint32_t*)&info[10]); //seek to the place where img data begins
+
149 
+
150  uint32_t row_padded = (width * depth + 3) & (~3); //row size must be aligned to 4 bytes
+
151 
+
152  unsigned char data [row_padded]; //allocate space for one row (incl. padding)
+
153 
+
154  for (int i = 0; i < height; i++) { //for each row
+
155  filesystem_file_read(file, data, row_padded); //read row into buffer
+
156 
+
157  for (int j = 0; j < width * depth; j += depth) { //for each pixel
+
158  unsigned char a, r, g, b;
+
159 
+
160  if (depth == 4) { //a,r,g,b 8bit each
+
161  a = data[j];
+
162  r = data[j + 1];
+
163  g = data[j + 2];
+
164  b = data[j + 3];
+
165  } else if (depth == 3) { // b,g,r, 8bit each
+
166  a = 255;
+
167  r = data[j + 2];
+
168  g = data[j + 1];
+
169  b = data[j];
+
170  }
+
171 
+
172  if (a != 0) {
+
173  //bmp's are stored "bottom-up", so we start drawing at the bottom
+
174  tft_draw_pixel(x + j / depth, y + height - 1 - i, RGB(r, g, b));
+
175  }
+
176  }
+
177  }
+
178 
+
179  filesystem_file_close(file);
+
180 
+
181  return true;
+
182 
+
183 }
+
FILE_STATUS filesystem_file_seek(FILE_HANDLE *handle, uint32_t offset)
Definition: filesystem.c:43
+
#define RGB(r, g, b)
Definition: tft.h:48
+ +
uint16_t y
Definition: pixy.h:81
+
FILE_HANDLE * filesystem_file_open(const char *filename)
Definition: filesystem.c:33
+
void filesystem_file_close(FILE_HANDLE *handle)
Definition: filesystem.c:38
+
void tft_draw_pixel(uint16_t x, uint16_t y, uint16_t color)
Definition: tft.c:56
+
uint16_t height
Definition: pixy.h:83
+
uint16_t width
Definition: pixy.h:82
+
Everything ok.
Definition: filesystem.h:91
+
uint16_t x
Definition: pixy.h:80
+
FILE_STATUS filesystem_file_read(FILE_HANDLE *handle, uint8_t *buf, uint32_t size)
Definition: filesystem.c:48
+

Here is the call graph for this function:
@@ -411,6 +507,16 @@ Here is the caller graph for this function:
+

Definition at line 72 of file tft.c.

+
73 {
+ +
75 }
+
uint16_t y
Definition: pixy.h:81
+
uint16_t height
Definition: pixy.h:83
+
uint16_t width
Definition: pixy.h:82
+
uint16_t x
Definition: pixy.h:80
+
void ll_tft_draw_bitmap_unscaled(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint16_t *dat)
+

Here is the call graph for this function:
@@ -476,6 +582,14 @@ Here is the caller graph for this function:
+

Definition at line 77 of file tft.c.

+
78 {
+
79  ll_tft_draw_circle(x, y, r, color);
+
80 }
+
void ll_tft_draw_circle(uint16_t x, uint16_t y, uint16_t r, uint16_t color)
+
uint16_t y
Definition: pixy.h:81
+
uint16_t x
Definition: pixy.h:80
+

Here is the call graph for this function:
@@ -548,6 +662,12 @@ Here is the caller graph for this function:
+

Definition at line 50 of file tft.c.

+
51 {
+
52  ll_tft_draw_line(x1, y1, x2, y2, color);
+
53 }
+
void ll_tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
+

Here is the call graph for this function:
@@ -606,6 +726,14 @@ Here is the caller graph for this function:
+

Definition at line 56 of file tft.c.

+
57 {
+
58  ll_tft_draw_pixel(x, y, color);
+
59 }
+
uint16_t y
Definition: pixy.h:81
+
void ll_tft_draw_pixel(uint16_t x, uint16_t y, uint16_t color)
+
uint16_t x
Definition: pixy.h:80
+

Here is the call graph for this function:
@@ -678,6 +806,13 @@ Here is the caller graph for this function:
+

Definition at line 61 of file tft.c.

+
62 {
+
63  //could be implemented with 4 lines instead of introducing a ll func
+
64  ll_tft_draw_rectangle(x1, y1, x2, y2, color);
+
65 }
+
void ll_tft_draw_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
+

Here is the call graph for this function:
@@ -750,6 +885,12 @@ Here is the caller graph for this function:
+

Definition at line 67 of file tft.c.

+
68 {
+
69  ll_tft_fill_rectangle(x1, y1, x2, y2, color);
+
70 }
+
void ll_tft_fill_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
+

Here is the call graph for this function:
@@ -791,6 +932,12 @@ Here is the caller graph for this function:
Returns
The height in pixel
+

Definition at line 87 of file tft.c.

+
88 {
+
89  return ll_tft_font_height(fontnum);
+
90 }
+
uint8_t ll_tft_font_height(uint8_t fontnum)
+

Here is the call graph for this function:
@@ -832,6 +979,12 @@ Here is the caller graph for this function:
Returns
The width in pixel
+

Definition at line 92 of file tft.c.

+
93 {
+
94  return ll_tft_font_width(fontnum);
+
95 }
+
uint8_t ll_tft_font_width(uint8_t fontnum)
+

Here is the call graph for this function:
@@ -866,6 +1019,13 @@ Here is the caller graph for this function:

Initializes the display. Call this method before using any tft_* functions

Returns
true on success
+

Definition at line 39 of file tft.c.

+
40 {
+
41  return ll_tft_init();
+
42 
+
43 }
+
bool ll_tft_init()
+

Here is the call graph for this function:
@@ -900,6 +1060,12 @@ Here is the caller graph for this function:

Queries the number of available fonts

Returns
+

Definition at line 82 of file tft.c.

+
83 {
+
84  return ll_tft_num_fonts();
+
85 }
+
uint8_t ll_tft_num_fonts()
+

Here is the call graph for this function:
@@ -977,6 +1143,21 @@ Here is the call graph for this function:
+

Definition at line 111 of file tft.c.

+
112 {
+
113  static char buffer[128]; //buffer to save the formatted text into
+
114 
+
115  //Since we have variable arguments, we need to forward them. We have to use vsprintf instead of sprintf for that.
+
116  va_list args;
+
117  va_start(args, format); //start the varg-list
+
118  vsprintf(buffer, format, args); //let vsprintf render the formatted string
+
119  tft_print_line(x, y, color, bgcolor, font, buffer); //print the string as normal text
+
120  va_end(args); //end the varg-list
+
121 }
+
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
+
uint16_t y
Definition: pixy.h:81
+
uint16_t x
Definition: pixy.h:80
+

Here is the call graph for this function:
@@ -1056,6 +1237,23 @@ Here is the caller graph for this function:
+

Definition at line 98 of file tft.c.

+
99 {
+
100  if (font >= ll_tft_num_fonts()) {
+
101  return; //invalid font index
+
102  }
+
103 
+
104  for (int i = 0; i < strlen(text); i++) { //for each char in the line
+
105  ll_tft_draw_char(x, y, color, bgcolor, font, text[i]); //draw the char
+
106  x += ll_tft_font_width(font); //and increase the x position
+
107  }
+
108 }
+
uint16_t y
Definition: pixy.h:81
+
uint8_t ll_tft_font_width(uint8_t fontnum)
+
uint8_t ll_tft_num_fonts()
+
void ll_tft_draw_char(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, char c)
+
uint16_t x
Definition: pixy.h:80
+

Here is the call graph for this function:
@@ -1079,7 +1277,7 @@ Here is the caller graph for this function:
diff --git a/group__touch.html b/group__touch.html index 2b1d806..47af91b 100644 --- a/group__touch.html +++ b/group__touch.html @@ -118,13 +118,13 @@ Enumerations }   enum  TOUCH_ACTION {
-  NONE =0x00, -PEN_DOWN =0x01, -PEN_UP =0x02, -PEN_ENTER =0x04, +  NONE = 0x00, +PEN_DOWN = 0x01, +PEN_UP = 0x02, +PEN_ENTER = 0x04,
-  PEN_LEAVE =0x08, -PEN_MOVE =0x10 +  PEN_LEAVE = 0x08, +PEN_MOVE = 0x10
}   @@ -169,6 +169,8 @@ Functions +

Definition at line 67 of file touch.h.

+

Enumeration Type Documentation

@@ -203,6 +205,23 @@ Functions +

Definition at line 52 of file touch.h.

+
52  {
+
53  NONE = 0x00,
+
54  PEN_DOWN = 0x01,
+
55  PEN_UP = 0x02,
+
56  PEN_ENTER = 0x04,
+
57  PEN_LEAVE = 0x08,
+
58  PEN_MOVE = 0x10
+
59 } TOUCH_ACTION;
+
TOUCH_ACTION
Definition: touch.h:52
+
Receive an event when the pen moves inside the region (pen is down)
Definition: touch.h:58
+
Receive an event when the pen goes down inside the region.
Definition: touch.h:54
+
Receive an event when the pen goes up inside the region.
Definition: touch.h:55
+
Receive an event when the pen enters the region (pen was down before)
Definition: touch.h:56
+
Do not receive any events.
Definition: touch.h:53
+
Receive an event when the pen leaves the region (pen was inside region before)
Definition: touch.h:57
+
@@ -224,6 +243,15 @@ Functions +

Definition at line 43 of file touch.h.

+
43  {
+
44  TOUCH_UP,
+
45  TOUCH_DOWN
+
46 } TOUCH_STATE ;
+
The display is currently not touched.
Definition: touch.h:44
+
The display is currently touched at some point.
Definition: touch.h:45
+
TOUCH_STATE
Definition: touch.h:43
+

Function Documentation

@@ -266,6 +294,123 @@ Functions
Returns
True on success
+

Definition at line 72 of file touch.c.

+
73 {
+
74  //Update current and old position/state
+
75  bool penDown = (state == TOUCH_DOWN);
+
76  bool oldPenDown = (oldState == TOUCH_DOWN);
+
77  oldState = state;
+
78 
+
79  if (calibration) { //If in Calibration mode
+
80  if (penDown) {
+
81  pos.x = touchX;
+
82  pos.y = touchY;
+
83  } else {
+
84  if (oldPenDown) { //Run only if we got at least one pen down
+
85  calibration = 0; //Calibration finish (Touch X and Y are the values from the last measure, where the pen was down)
+
86  }
+
87  }
+
88 
+
89  return true;
+
90  }
+
91 
+
92  //If we reach this point we're not in calibration mode and we need to process the event and call the registred handlers..
+
93 
+
94  if (use_calibration) { //the underlying touch hardware uses calibration
+
95  //Calculate the real touch position out of the passed ones, and the calibration values
+
96  pos.x = touchX = (((long)(DWIDTH - 2 * CCENTER) * 2 * (long)((long)touchX - cal_xs) / cal_dx + 1) >> 1) + CCENTER;
+
97  pos.y = touchY = (((long)(DHEIGHT - 2 * CCENTER) * 2 * (long)((long)touchY - cal_ys) / cal_dy + 1) >> 1) + CCENTER;
+
98  } else { //no conversion needed for the underlying hardware
+
99  pos.x = touchX;
+
100  pos.y = touchY;
+
101  }
+
102 
+
103  if (penDown) { //pen is down now
+
104  //tft_draw_pixel(touchX,touchY,WHITE);
+
105  if (!oldPenDown) { //pen wasn't down before (positive edge) => First Touch
+
106  for (int z = 0; z < NUM_AREAS; z++) { // For every touch area
+
107  //Check if pos is inside area
+
108  if (areas[z] != NULL && touchX >= areas[z]->x1 && touchX <= areas[z]->x2 && touchY >= areas[z]->y1 && touchY <= areas[z]->y2) {
+
109  areas[z]->flags = 1; //Save PenInside=1
+
110 
+
111  if (areas[z]->hookedActions & PEN_DOWN) { //The user wants to receive pen down events
+
112  areas[z]->callback(areas[z], PEN_DOWN); //Send event to user callback
+
113  }
+
114  }
+
115  }
+
116  } else { //Pen was down before => Second, Third event in row
+
117  for (int z = 0; z < NUM_AREAS; z++) { // For every touch area
+
118  if (areas[z] != NULL) {
+
119  //Check if pos is inside area
+
120  if (touchX >= areas[z]->x1 && touchX <= areas[z]->x2 && touchY >= areas[z]->y1 && touchY <= areas[z]->y2) {
+
121  if (areas[z]->flags == 0) { //Pen was not inside before (PenInside==0)
+
122  areas[z]->flags = 1; //Pen is inside now (PenInside=1)
+
123 
+
124  if (areas[z]->hookedActions & PEN_ENTER) { //The user wants to receive pen enter events
+
125  areas[z]->callback(areas[z], PEN_ENTER);
+
126  }
+
127  }
+
128  } else if (areas[z]->flags) { //Pos not inside area, but it was before (PenInside==1)
+
129  areas[z]->flags = 0; //Pen is no longer inside (PenInside=0)
+
130 
+
131  if (areas[z]->hookedActions & PEN_LEAVE) { //The user wants to receive pen leave events
+
132  areas[z]->callback(areas[z], PEN_LEAVE);
+
133  }
+
134  }
+
135  }
+
136  }
+
137  }
+
138 
+
139  for (int z = 0; z < NUM_AREAS; z++) { // For every touch area
+
140  if (areas[z] != NULL && (areas[z]->hookedActions & PEN_MOVE)) { //User want's to receive pen move events
+
141  //Check if pos is inside area
+
142  if (touchX >= areas[z]->x1 && touchX <= areas[z]->x2 && touchY >= areas[z]->y1 && touchY <= areas[z]->y2) {
+
143  areas[z]->callback(areas[z], PEN_MOVE);
+
144  }
+
145  }
+
146  }
+
147  } else { //pen is not down now
+
148  if (oldPenDown) { //but it was down before (negative edge)
+
149  for (int z = 0; z < NUM_AREAS; z++) { // For every touch area
+
150  //Check if pos is inside area
+
151  if (areas[z] != NULL && touchX >= areas[z]->x1 && touchX <= areas[z]->x2 && touchY >= areas[z]->y1 && touchY <= areas[z]->y2) {
+
152  areas[z]->flags = 0; //The pen is no longer inside (PenInside = 0);
+
153 
+
154  if (areas[z]->hookedActions & PEN_UP) { //user want's to receive pen up events
+
155  areas[z]->callback(areas[z], PEN_UP);
+
156  }
+
157  }
+
158  }
+
159  }
+
160  }
+
161 
+
162  return true;
+
163 }
+
Receive an event when the pen moves inside the region (pen is down)
Definition: touch.h:58
+
Receive an event when the pen goes down inside the region.
Definition: touch.h:54
+
#define CCENTER
+
Receive an event when the pen goes up inside the region.
Definition: touch.h:55
+
uint16_t y
The Y-Coordinate of the point.
Definition: touch.h:88
+
int cal_ys
Definition: touch.c:47
+
uint8_t flags
For internal use, don't change, don't initialize.
Definition: touch.h:79
+
uint16_t x
The X-Coordinate of the point.
Definition: touch.h:87
+
#define DHEIGHT
+
The display is currently touched at some point.
Definition: touch.h:45
+
static enum @0 state
+
volatile POINT_STRUCT pos
Definition: touch.c:38
+
volatile TOUCH_STATE oldState
Definition: touch.c:39
+
TOUCH_CALLBACK callback
Callback which is executed when an event occurred in this Area.
Definition: touch.h:78
+
#define NUM_AREAS
Definition: touch.c:35
+
Receive an event when the pen enters the region (pen was down before)
Definition: touch.h:56
+
volatile bool calibration
Definition: touch.c:40
+
bool use_calibration
Definition: touch.c:42
+
int cal_xs
Definition: touch.c:45
+
#define DWIDTH
+
TOUCH_AREA_STRUCT * areas[NUM_AREAS]
Definition: touch.c:36
+
int cal_dy
Definition: touch.c:48
+
int cal_dx
Definition: touch.c:46
+
Receive an event when the pen leaves the region (pen was inside region before)
Definition: touch.h:57
+
@@ -282,6 +427,12 @@ Functions

Gets the last touched point

Returns
The Coordinates of the last touched points
+

Definition at line 211 of file touch.c.

+
212 {
+
213  return pos;
+
214 }
+
volatile POINT_STRUCT pos
Definition: touch.c:38
+

Here is the caller graph for this function:
@@ -314,6 +465,24 @@ Here is the caller graph for this function:
Returns
True if there's enough memory to allocate num TOUCH_AREAs
+

Definition at line 165 of file touch.c.

+
166 {
+
167  //go through pointer array and check for free spaces
+
168  for (unsigned char i = 0; i < NUM_AREAS; i++) {
+
169  if (areas[i] == NULL) {
+
170  num--; //a free space was found, we need one less
+
171  }
+
172 
+
173  if (num == 0) {
+
174  return true; //enough free spaces found
+
175  }
+
176  }
+
177 
+
178  return false; //not enough free spaces found
+
179 }
+
#define NUM_AREAS
Definition: touch.c:35
+
TOUCH_AREA_STRUCT * areas[NUM_AREAS]
Definition: touch.c:36
+

Here is the caller graph for this function:
@@ -339,6 +508,12 @@ Here is the caller graph for this function:

Initializes the Touch Controller. Call this method before using any touch_* functions

Returns
true on success
+

Definition at line 61 of file touch.c.

+
62 {
+
63  return ll_touch_init();
+
64 }
+
bool ll_touch_init()
+

Here is the call graph for this function:
@@ -380,6 +555,23 @@ Here is the caller graph for this function:
Returns
True if everything was successful and the corresponding Touch Area will be monitored from now on
+

Definition at line 181 of file touch.c.

+
182 {
+
183  //go through pointer array and check for free space
+
184  for (unsigned char i = 0; i < NUM_AREAS; i++) {
+
185  if (areas[i] == NULL) { //free space found
+
186  area->flags = 0; //we start with empty flags (PenInside=0)
+
187  areas[i] = area; //save pointer into list
+
188  return true;
+
189  }
+
190  }
+
191 
+
192  return false; //no free space found
+
193 }
+
uint8_t flags
For internal use, don't change, don't initialize.
Definition: touch.h:79
+
#define NUM_AREAS
Definition: touch.c:35
+
TOUCH_AREA_STRUCT * areas[NUM_AREAS]
Definition: touch.c:36
+

Here is the caller graph for this function:
@@ -436,6 +628,18 @@ Here is the caller graph for this function:
+

Definition at line 51 of file touch.c.

+
52 {
+
53  cal_xs = xs;
+
54  cal_ys = ys;
+
55  cal_dx = dx;
+
56  cal_dy = dy;
+
57 }
+
int cal_ys
Definition: touch.c:47
+
int cal_xs
Definition: touch.c:45
+
int cal_dy
Definition: touch.c:48
+
int cal_dx
Definition: touch.c:46
+

Here is the caller graph for this function:
@@ -467,6 +671,12 @@ Here is the caller graph for this function:
+

Definition at line 66 of file touch.c.

+
67 {
+
68  use_calibration = uc;
+
69 }
+
bool use_calibration
Definition: touch.c:42
+
@@ -489,6 +699,23 @@ Here is the caller graph for this function: +

Definition at line 195 of file touch.c.

+
196 {
+
197  if (area == NULL) {
+
198  return;
+
199  }
+
200 
+
201  //go through pointer array and find the area to remove
+
202  for (unsigned char i = 0; i < NUM_AREAS; i++) {
+
203  if (areas[i] == area) { //area found in pointer array at pos i
+
204  areas[i] = NULL; //set pointer in list to NULL again
+
205  break;
+
206  }
+
207  }
+
208 }
+
#define NUM_AREAS
Definition: touch.c:35
+
TOUCH_AREA_STRUCT * areas[NUM_AREAS]
Definition: touch.c:36
+

Here is the caller graph for this function:
@@ -503,7 +730,7 @@ Here is the caller graph for this function:
diff --git a/group__tracking.html b/group__tracking.html index 71a7fc4..1936799 100644 --- a/group__tracking.html +++ b/group__tracking.html @@ -127,6 +127,14 @@ Functions +

Definition at line 31 of file screen_tracking.h.

+
31  {
+
32  OUR_TRACKING,
+ +
34 };
+
Pixy's internal tracking implementation.
+
Our own tracking PID implementation.
+

Function Documentation

@@ -145,6 +153,12 @@ Functions

Returns a pointer to the tracking screen

See also
gui_screen_navigate
Returns
+

Definition at line 418 of file screen_tracking.c.

+
419 {
+
420  return &screen;
+
421 }
+
static SCREEN_STRUCT screen
+

Here is the caller graph for this function:
@@ -176,6 +190,29 @@ Here is the caller graph for this function:
+

Definition at line 210 of file screen_tracking.c.

+
211 {
+
212  //Depending on the enum value let tracking_current point to a different setting/callback structure
+
213  switch (impl) {
+
214  case OUR_TRACKING:
+ +
216  break;
+
217 
+
218  case REFERENCE_TRACKING:
+ +
220  break;
+
221 
+
222  default:
+
223  tracking_current = NULL;
+
224  break;
+
225  }
+
226 }
+
static TRACKING_CONFIG_STRUCT tracking_our
+
static TRACKING_CONFIG_STRUCT * tracking_current
+
Pixy's internal tracking implementation.
+
static TRACKING_CONFIG_STRUCT tracking_reference
+
Our own tracking PID implementation.
+

Here is the caller graph for this function:
@@ -190,7 +227,7 @@ Here is the caller graph for this function:
diff --git a/index.html b/index.html index 79469c4..bf4cbb1 100644 --- a/index.html +++ b/index.html @@ -84,7 +84,7 @@ A good point to start is probably the Modules page. < diff --git a/ll__filesystem_8h.html b/ll__filesystem_8h.html index 661a1ef..8196159 100644 --- a/ll__filesystem_8h.html +++ b/ll__filesystem_8h.html @@ -131,7 +131,7 @@ Functions diff --git a/ll__filesystem_8h_source.html b/ll__filesystem_8h_source.html index f330b14..cd71e70 100644 --- a/ll__filesystem_8h_source.html +++ b/ll__filesystem_8h_source.html @@ -89,38 +89,52 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
ll_filesystem.h
-Go to the documentation of this file.
1 #include "filesystem.h"
-
2 
-
7 
-
13 
-
18 
-
19 
-
20 bool ll_filesystem_init();
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/lowlevel/ll_filesystem.h
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-05-10 timolang@gmail.com e2bce8f Added filesystem module, tests and implementation for it in emulator.
+
11 * 2015-05-15 timolang@gmail.com 9a16865 Added doxgen comments to filesyste, checkbox, numupdown and screen module. And some minor changes to the other modules.
+
12 *
+
13 **************************************************************************************************************************************/
+
14 
+
15 #include "filesystem.h"
+
16 
21 
-
22 DIRECTORY_STRUCT* ll_filesystem_dir_open(const char* path);
- -
24 FILE_HANDLE* ll_filesystem_file_open(const char* filename);
- -
26 FILE_STATUS ll_filesystem_file_seek(FILE_HANDLE* handle, uint32_t offset);
-
27 FILE_STATUS ll_filesystem_file_read(FILE_HANDLE* handle, uint8_t* buf, uint32_t size);
-
28 FILE_STATUS ll_filesystem_file_write(FILE_HANDLE* handle, uint8_t* buf, uint32_t size);
-
29 
+
27 
+
32 
+
33 
+
34 bool ll_filesystem_init();
+
35 
+
36 DIRECTORY_STRUCT* ll_filesystem_dir_open(const char* path);
+ +
38 FILE_HANDLE* ll_filesystem_file_open(const char* filename);
+ +
40 FILE_STATUS ll_filesystem_file_seek(FILE_HANDLE* handle, uint32_t offset);
+
41 FILE_STATUS ll_filesystem_file_read(FILE_HANDLE* handle, uint8_t* buf, uint32_t size);
+
42 FILE_STATUS ll_filesystem_file_write(FILE_HANDLE* handle, uint8_t* buf, uint32_t size);
+
43 
FILE_STATUS ll_filesystem_file_seek(FILE_HANDLE *handle, uint32_t offset)
bool ll_filesystem_init()
void ll_filesystem_file_close(FILE_HANDLE *handle)
FILE_STATUS ll_filesystem_file_write(FILE_HANDLE *handle, uint8_t *buf, uint32_t size)
FILE_STATUS ll_filesystem_file_read(FILE_HANDLE *handle, uint8_t *buf, uint32_t size)
-
Definition: filesystem.h:66
+ -
Definition: filesystem.h:57
+
void ll_filesystem_dir_close(DIRECTORY_STRUCT *dir)
DIRECTORY_STRUCT * ll_filesystem_dir_open(const char *path)
-
FILE_STATUS
Definition: filesystem.h:75
+
FILE_STATUS
Definition: filesystem.h:90
FILE_HANDLE * ll_filesystem_file_open(const char *filename)
diff --git a/ll__system_8h.html b/ll__system_8h.html index 5d8a542..2c43e14 100644 --- a/ll__system_8h.html +++ b/ll__system_8h.html @@ -122,7 +122,7 @@ Functions
diff --git a/ll__system_8h_source.html b/ll__system_8h_source.html index 13c215b..e3fafd6 100644 --- a/ll__system_8h_source.html +++ b/ll__system_8h_source.html @@ -89,19 +89,37 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
ll_system.h
-Go to the documentation of this file.
1 #include <stdbool.h>
-
2 #include <stdint.h>
-
3 
-
4 
-
10 
-
17 
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/lowlevel/ll_system.h
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-04-03 timolang@gmail.com 1f2af9f Added more tft functions to common and emulator. Fixed eventloop.
+
11 * 2015-04-03 timolang@gmail.com cab8609 Integrated pixy into emulator. Pixy is no longer in the common/libs folder but in emulator/libs and discovery/libs
+
12 * 2015-04-03 timolang@gmail.com 9a1d12a Refactored discovery, to use new project structure. Almost ready.
+
13 * 2015-04-25 timolang@gmail.com 3d1e4b2 Simplified code a bit. Emulator does not work stable when replugging pixy.
+
14 * 2015-04-25 timolang@gmail.com 0858b0d Fixed some bugs when receiving large data.
+
15 * 2015-05-15 timolang@gmail.com 9a16865 Added doxgen comments to filesyste, checkbox, numupdown and screen module. And some minor changes to the other modules.
+
16 *
+
17 **************************************************************************************************************************************/
+
18 
+
19 #include <stdbool.h>
+
20 #include <stdint.h>
+
21 
22 
-
23 
-
24 bool ll_system_init();
-
25 void ll_system_delay(uint32_t msec);
-
26 void ll_system_process();
-
28 
+
35 
+
40 
+
41 
+
42 bool ll_system_init();
+
43 void ll_system_delay(uint32_t msec);
+
44 void ll_system_process();
+ +
46 
bool ll_system_init()
void ll_system_toggle_led()
void ll_system_process()
@@ -109,7 +127,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
diff --git a/ll__tft_8h.html b/ll__tft_8h.html index dcfc470..8ce9dc8 100644 --- a/ll__tft_8h.html +++ b/ll__tft_8h.html @@ -138,7 +138,7 @@ Functions
diff --git a/ll__tft_8h_source.html b/ll__tft_8h_source.html index 086bf90..a180dc6 100644 --- a/ll__tft_8h_source.html +++ b/ll__tft_8h_source.html @@ -89,31 +89,52 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
ll_tft.h
-Go to the documentation of this file.
1 #include <stdint.h>
-
2 #include <stdbool.h>
-
3 
-
4 
-
9 
-
15 
-
20 
-
21 // init functions
-
22 bool ll_tft_init();
-
23 
-
24 // draw functions
-
25 void ll_tft_clear(uint16_t color);
-
26 void ll_tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
-
27 void ll_tft_draw_pixel(uint16_t x,uint16_t y,uint16_t color);
-
28 void ll_tft_draw_rectangle(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2, uint16_t color);
-
29 void ll_tft_fill_rectangle(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2, uint16_t color);
-
30 void ll_tft_draw_bitmap_unscaled(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint16_t *dat);
-
31 void ll_tft_draw_circle(uint16_t x, uint16_t y, uint16_t r, uint16_t color);
-
32 
-
33 
-
34 uint8_t ll_tft_num_fonts();
-
35 uint8_t ll_tft_font_height(uint8_t fontnum);
-
36 uint8_t ll_tft_font_width(uint8_t fontnum);
-
37 void ll_tft_draw_char(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, char c);
-
38 
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/lowlevel/ll_tft.h
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-04-03 timolang@gmail.com 51089aa Refactored Project Structure for use with emulator
+
11 * 2015-04-03 timolang@gmail.com 1f2af9f Added more tft functions to common and emulator. Fixed eventloop.
+
12 * 2015-04-03 timolang@gmail.com 9a1d12a Refactored discovery, to use new project structure. Almost ready.
+
13 * 2015-04-03 timolang@gmail.com 1aa9194 Fixed Drawing of rects in Emulator. Got frames from pixy to emulator. Slooooow.
+
14 * 2015-04-27 aaron@duckpond.ch aed90ef Drawcircle added (emulator)
+
15 * 2015-04-27 timolang@gmail.com e249fb2 Added font support
+
16 * 2015-04-27 aaron@duckpond.ch f0a6c3b Implemented init functions for gpio, fsmc and display
+
17 * 2015-04-27 aaron@duckpond.ch 0b61f21 Fixed misplacement of prototypes in ll_tft.h and implemented a propper init function.
+
18 * 2015-05-15 timolang@gmail.com 9a16865 Added doxgen comments to filesyste, checkbox, numupdown and screen module. And some minor changes to the other modules.
+
19 *
+
20 **************************************************************************************************************************************/
+
21 
+
22 #include <stdint.h>
+
23 #include <stdbool.h>
+
24 
+
25 
+
30 
+
36 
+
41 
+
42 // init functions
+
43 bool ll_tft_init();
+
44 
+
45 // draw functions
+
46 void ll_tft_clear(uint16_t color);
+
47 void ll_tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
+
48 void ll_tft_draw_pixel(uint16_t x, uint16_t y, uint16_t color);
+
49 void ll_tft_draw_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
+
50 void ll_tft_fill_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
+
51 void ll_tft_draw_bitmap_unscaled(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint16_t* dat);
+
52 void ll_tft_draw_circle(uint16_t x, uint16_t y, uint16_t r, uint16_t color);
+
53 
+
54 
+
55 uint8_t ll_tft_num_fonts();
+
56 uint8_t ll_tft_font_height(uint8_t fontnum);
+
57 uint8_t ll_tft_font_width(uint8_t fontnum);
+
58 void ll_tft_draw_char(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, char c);
+
59 
void ll_tft_draw_circle(uint16_t x, uint16_t y, uint16_t r, uint16_t color)
uint8_t ll_tft_font_width(uint8_t fontnum)
uint8_t ll_tft_num_fonts()
@@ -129,7 +150,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
diff --git a/ll__touch_8h.html b/ll__touch_8h.html index 17b84f3..f5da35d 100644 --- a/ll__touch_8h.html +++ b/ll__touch_8h.html @@ -116,7 +116,7 @@ Functions
diff --git a/ll__touch_8h_source.html b/ll__touch_8h_source.html index c1855cc..8f24f7d 100644 --- a/ll__touch_8h_source.html +++ b/ll__touch_8h_source.html @@ -89,20 +89,34 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
ll_touch.h
-Go to the documentation of this file.
1 #include <stdint.h>
-
2 #include <stdbool.h>
-
3 
-
8 
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/lowlevel/ll_touch.h
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-04-27 timolang@gmail.com 259d446 Added touch support to emulator. Implemented basic touch function.
+
11 * 2015-05-15 timolang@gmail.com 9a16865 Added doxgen comments to filesyste, checkbox, numupdown and screen module. And some minor changes to the other modules.
+
12 *
+
13 **************************************************************************************************************************************/
14 
-
19 
-
20 
-
21 bool ll_touch_init();
+
15 #include <stdint.h>
+
16 #include <stdbool.h>
+
17 
22 
+
28 
+
33 
+
34 
+
35 bool ll_touch_init();
+
36 
bool ll_touch_init()
diff --git a/modules.html b/modules.html index f9c05e3..1b613d2 100644 --- a/modules.html +++ b/modules.html @@ -113,7 +113,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
diff --git a/numupdown_8c.html b/numupdown_8c.html index 3d7025c..e002829 100644 --- a/numupdown_8c.html +++ b/numupdown_8c.html @@ -106,7 +106,9 @@ Include dependency graph for numupdown.c: - + +

Go to the source code of this file.

+
@@ -140,6 +142,8 @@ Functions

Macros

#define BASE_COLOR   RGB(90,90,90)
+

Definition at line 31 of file numupdown.c.

+

Function Documentation

@@ -157,6 +161,26 @@ Functions
+

Definition at line 50 of file numupdown.c.

+
51 {
+
52  //Get the pointer to the numupdown: subtract the offset of the buttonDown member in the struct from the button pointer
+
53  NUMUPDOWN_STRUCT* element = button - offsetof(NUMUPDOWN_STRUCT, buttonDown);
+
54 
+
55  if (element->value > element->min) { //old value lies above the minimum
+
56  element->value--; //let's decrease the value
+
57  gui_numupdown_update(element); //and redraw everything
+
58 
+
59  if (element->callback != NULL) { //the user provided a callback
+
60  element->callback(element, element->value); //Call the user callback with the new value
+
61  }
+
62  }
+
63 }
+
NUMUPDOWN_CALLBACK callback
Callback which is executed when the value changes.
Definition: numupdown.h:55
+ +
int16_t min
The minimum possible value (inclusive)
Definition: numupdown.h:53
+
void gui_numupdown_update(NUMUPDOWN_STRUCT *numupdown)
Definition: numupdown.c:154
+
int16_t value
The current/default value.
Definition: numupdown.h:52
+

Here is the call graph for this function:
@@ -191,6 +215,26 @@ Here is the caller graph for this function:
+

Definition at line 34 of file numupdown.c.

+
35 {
+
36  //Get the pointer to the numupdown: subtract the offset of the buttonUp member in the struct from the button pointer
+
37  NUMUPDOWN_STRUCT* element = button - offsetof(NUMUPDOWN_STRUCT, buttonUp);
+
38 
+
39  if (element->value < element->max) { //old value lies below the maximum
+
40  element->value++; //let's increase the value
+
41  gui_numupdown_update(element); //and redraw everything
+
42 
+
43  if (element->callback != NULL) { //the user provided a callback
+
44  element->callback(element, element->value); //Call the user callback with the new value
+
45  }
+
46  }
+
47 }
+
NUMUPDOWN_CALLBACK callback
Callback which is executed when the value changes.
Definition: numupdown.h:55
+
int16_t max
The maximum possible value (inclusive)
Definition: numupdown.h:54
+ +
void gui_numupdown_update(NUMUPDOWN_STRUCT *numupdown)
Definition: numupdown.c:154
+
int16_t value
The current/default value.
Definition: numupdown.h:52
+

Here is the call graph for this function:
@@ -233,6 +277,20 @@ Here is the caller graph for this function:
+

Definition at line 66 of file numupdown.c.

+
67 {
+
68  uint8_t width = 1 + (val < 0); //1 if positive, 2 if negative (to let space for sign)
+
69  val = abs(val); //Make the number positive
+
70 
+
71  while (val >= 10) { //while we have two or more digits
+
72  val /= 10; //remove one digit
+
73  width++; //add one character
+
74  }
+
75 
+
76  return width;
+
77 }
+
uint16_t width
Definition: pixy.h:82
+

Here is the caller graph for this function:
@@ -247,7 +305,7 @@ Here is the caller graph for this function:
diff --git a/numupdown_8c_source.html b/numupdown_8c_source.html new file mode 100644 index 0000000..a86c5a9 --- /dev/null +++ b/numupdown_8c_source.html @@ -0,0 +1,311 @@ + + + + + + +discoverpixy: common/gui/numupdown.c Source File + + + + + + + + + + +
+
+ + + + + + +
+
discoverpixy +
+
+
+ + + + + + +
+
+ + +
+ +
+ + +
+
+
+
numupdown.c
+
+
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/gui/numupdown.c
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-04-30 timolang@gmail.com 76ea9d8 Added num up down support.
+
11 * 2015-04-30 timolang@gmail.com b491b78 Made numupdown horizontal
+
12 * 2015-05-15 timolang@gmail.com 9a16865 Added doxgen comments to filesyste, checkbox, numupdown and screen module. And some minor changes to the other modules.
+
13 * 2015-05-17 timolang@gmail.com 2d46336 Improved comments in implementation of button, checkbox, numupdown, tft, touch and screen modules/submodules.
+
14 *
+
15 **************************************************************************************************************************************/
+
16 
+
17 #include "tft.h"
+
18 #include "touch.h"
+
19 #include "button.h"
+
20 #include "numupdown.h"
+
21 #include <stdio.h> //for sprintf
+
22 #include <stddef.h> //for offsetof macro
+
23 #include <stdlib.h> //for abs
+
24 
+
25 /* The idea is as follows:
+
26  * When the user add's a numupdown we create two buttons, one with a plus and one with a minus sign in it
+
27  * When the user presses one of the buttons we check and increase the value and execute the provided user callback
+
28  */
+
29 
+
30 
+
31 #define BASE_COLOR RGB(90,90,90) //Background color for the whole element
+
32 
+
33 //Callback which is called when the user presses the "plus" button
+
34 void button_up_cb(void* button)
+
35 {
+
36  //Get the pointer to the numupdown: subtract the offset of the buttonUp member in the struct from the button pointer
+
37  NUMUPDOWN_STRUCT* element = button - offsetof(NUMUPDOWN_STRUCT, buttonUp);
+
38 
+
39  if (element->value < element->max) { //old value lies below the maximum
+
40  element->value++; //let's increase the value
+
41  gui_numupdown_update(element); //and redraw everything
+
42 
+
43  if (element->callback != NULL) { //the user provided a callback
+
44  element->callback(element, element->value); //Call the user callback with the new value
+
45  }
+
46  }
+
47 }
+
48 
+
49 //Callback which is called when the user presses the "minus" button
+
50 void button_down_cb(void* button)
+
51 {
+
52  //Get the pointer to the numupdown: subtract the offset of the buttonDown member in the struct from the button pointer
+
53  NUMUPDOWN_STRUCT* element = button - offsetof(NUMUPDOWN_STRUCT, buttonDown);
+
54 
+
55  if (element->value > element->min) { //old value lies above the minimum
+
56  element->value--; //let's decrease the value
+
57  gui_numupdown_update(element); //and redraw everything
+
58 
+
59  if (element->callback != NULL) { //the user provided a callback
+
60  element->callback(element, element->value); //Call the user callback with the new value
+
61  }
+
62  }
+
63 }
+
64 
+
65 //Method to calculate the number of characters needed to print the provided number in decimal notation (with optional sign)
+
66 static uint8_t calc_text_width(int16_t val)
+
67 {
+
68  uint8_t width = 1 + (val < 0); //1 if positive, 2 if negative (to let space for sign)
+
69  val = abs(val); //Make the number positive
+
70 
+
71  while (val >= 10) { //while we have two or more digits
+
72  val /= 10; //remove one digit
+
73  width++; //add one character
+
74  }
+
75 
+
76  return width;
+
77 }
+
78 
+
79 
+ +
81 {
+
82  if (touch_have_empty(2)) { //Check if the touch module can handle two additional areas
+
83  if (numupdown->min > numupdown->max) { //min is bigger than max?
+
84  return false; //invalid parameter
+
85  }
+
86 
+
87  if (numupdown->value < numupdown->min) { //value is smaller than min?
+
88  numupdown->value = numupdown->min; //normalize value
+
89  } else if (numupdown->value > numupdown->max) { //value is bigger than max?
+
90  numupdown->value = numupdown->max; //normalize value
+
91  }
+
92 
+
93  uint8_t tw1 = calc_text_width(numupdown->max); //Calculate character width to render maximum value
+
94  uint8_t tw2 = calc_text_width(numupdown->min); //Calculate character width to render minimum value
+
95 
+
96  if (tw2 > tw1) {
+
97  tw1 = tw2; //ensure tw1 contains the larger number of the two
+
98  }
+
99 
+
100  uint8_t width = tft_font_width(0) * (tw1 + 1); //Calculate width of the number area
+
101 
+
102  //Add "minus" button to the left side of the number area
+
103  numupdown->buttonDown.base.x1 = numupdown->x;
+
104  numupdown->buttonDown.base.y1 = numupdown->y;
+
105  numupdown->buttonDown.base.x2 = AUTO;
+
106  numupdown->buttonDown.base.y2 = numupdown->y + tft_font_height(0) * 2;
+
107  numupdown->buttonDown.text = "-";
+
108  numupdown->buttonDown.font = 0;
+
109  numupdown->buttonDown.bgcolor = BASE_COLOR;
+
110  numupdown->buttonDown.txtcolor = WHITE;
+
111  numupdown->buttonDown.callback = button_down_cb;
+
112  gui_button_add(&numupdown->buttonDown);
+
113 
+
114  //Add "plus" button to the right side of the number area
+
115  numupdown->buttonUp.base.x1 = numupdown->buttonDown.base.x2 + width + 2;
+
116  numupdown->buttonUp.base.y1 = numupdown->y;
+
117  numupdown->buttonUp.base.x2 = AUTO;
+
118  numupdown->buttonUp.base.y2 = numupdown->y + tft_font_height(0) * 2;
+
119  numupdown->buttonUp.text = "+";
+
120  numupdown->buttonUp.font = 0;
+
121  numupdown->buttonUp.bgcolor = BASE_COLOR;
+
122  numupdown->buttonUp.txtcolor = WHITE;
+
123  numupdown->buttonUp.callback = button_up_cb;
+
124  gui_button_add(&numupdown->buttonUp);
+
125 
+
126  //Draw background and label of the number area
+
127  tft_fill_rectangle(numupdown->buttonDown.base.x2 + 2, numupdown->y, numupdown->buttonDown.base.x2 + width, numupdown->buttonUp.base.y2, BASE_COLOR);
+
128  tft_print_formatted(numupdown->buttonDown.base.x2 + 2 + tft_font_width(0) / 2, numupdown->y + tft_font_height(0) / 2, numupdown->fgcolor, BASE_COLOR, 0, "%*d", tw1, numupdown->value);
+
129 
+
130  return true;
+
131  }
+
132 
+
133  return false; //not enough touch areas left
+
134 }
+
135 
+ +
137 {
+
138  //remove the two buttons, we have no other allocated resources
+
139  gui_button_remove(&numupdown->buttonUp);
+
140  gui_button_remove(&numupdown->buttonDown);
+
141 }
+
142 
+
143 
+ +
145 {
+
146  //redraw the two buttons
+
147  gui_button_redraw(&numupdown->buttonUp);
+
148  gui_button_redraw(&numupdown->buttonDown);
+
149 
+
150  //call update method which will take care of the number-area rendering
+
151  gui_numupdown_update(numupdown);
+
152 }
+
153 
+ +
155 {
+
156  //Calculate the number area width again (see above)
+
157  uint8_t tw1 = calc_text_width(numupdown->max);
+
158  uint8_t tw2 = calc_text_width(numupdown->min);
+
159 
+
160  if (tw2 > tw1) {
+
161  tw1 = tw2;
+
162  }
+
163 
+
164  uint8_t width = tft_font_width(0) * (tw1 + 1);
+
165 
+
166  //Draw background and label of the number area
+
167  tft_fill_rectangle(numupdown->buttonDown.base.x2 + 2, numupdown->y, numupdown->buttonDown.base.x2 + width, numupdown->buttonUp.base.y2, BASE_COLOR);
+
168  tft_print_formatted(numupdown->buttonDown.base.x2 + 2 + tft_font_width(0) / 2, numupdown->y + tft_font_height(0) / 2, numupdown->fgcolor, BASE_COLOR, 0, "%*d", tw1, numupdown->value);
+
169 }
+
uint8_t tft_font_height(uint8_t fontnum)
Definition: tft.c:87
+
const char * text
The label of the button.
Definition: button.h:61
+
uint8_t tft_font_width(uint8_t fontnum)
Definition: tft.c:92
+
void gui_button_redraw(BUTTON_STRUCT *button)
Definition: button.c:164
+
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
+
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
+
void tft_print_formatted(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, const char *format,...)
Definition: tft.c:111
+
bool gui_button_add(BUTTON_STRUCT *button)
Definition: button.c:133
+
uint16_t x1
Top Left X-Coordinate of Area.
Definition: touch.h:74
+
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
+ +
NUMUPDOWN_CALLBACK callback
Callback which is executed when the value changes.
Definition: numupdown.h:55
+
uint16_t y2
Bottom Right Y-Coordinate of Area.
Definition: touch.h:77
+
void button_down_cb(void *button)
Definition: numupdown.c:50
+ +
static uint8_t calc_text_width(int16_t val)
Definition: numupdown.c:66
+
uint16_t y
The y-Coordinate of the Top-Left Starting Point.
Definition: numupdown.h:50
+
int16_t max
The maximum possible value (inclusive)
Definition: numupdown.h:54
+ + + +
void gui_numupdown_remove(NUMUPDOWN_STRUCT *numupdown)
Definition: numupdown.c:136
+
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
+
void gui_button_remove(BUTTON_STRUCT *button)
Definition: button.c:184
+
int16_t min
The minimum possible value (inclusive)
Definition: numupdown.h:53
+
#define WHITE
Definition: tft.h:53
+
void tft_fill_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:67
+
void gui_numupdown_redraw(NUMUPDOWN_STRUCT *numupdown)
Definition: numupdown.c:144
+
uint16_t fgcolor
The 16-bit color of the value-text.
Definition: numupdown.h:51
+
BUTTON_STRUCT buttonDown
For internal use, don't change, don't initialize.
Definition: numupdown.h:58
+
void button_up_cb(void *button)
Definition: numupdown.c:34
+
void gui_numupdown_update(NUMUPDOWN_STRUCT *numupdown)
Definition: numupdown.c:154
+
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
+
bool touch_have_empty(unsigned char num)
Definition: touch.c:165
+
uint8_t font
The number of the font to use.
Definition: button.h:60
+
#define BASE_COLOR
Definition: numupdown.c:31
+
BUTTON_STRUCT buttonUp
For internal use, don't change, don't initialize.
Definition: numupdown.h:57
+
bool gui_numupdown_add(NUMUPDOWN_STRUCT *numupdown)
Definition: numupdown.c:80
+
+ + + + diff --git a/numupdown_8h.html b/numupdown_8h.html index 4c9945a..b68edcc 100644 --- a/numupdown_8h.html +++ b/numupdown_8h.html @@ -135,7 +135,7 @@ Functions diff --git a/numupdown_8h_source.html b/numupdown_8h_source.html index 3f05546..7fb7d97 100644 --- a/numupdown_8h_source.html +++ b/numupdown_8h_source.html @@ -89,59 +89,74 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
numupdown.h
-Go to the documentation of this file.
1 #ifndef NUMUPDOWN_H
-
2 #define NUMUPDOWN_H
-
3 
-
4 #include "button.h"
-
5 
-
10 
-
16 
-
21 
-
28 typedef void (*NUMUPDOWN_CALLBACK)(void *numupdown, int16_t value);
-
29 
-
33 typedef struct {
-
34  uint16_t x;
-
35  uint16_t y;
-
36  uint16_t fgcolor;
-
37  int16_t value;
-
38  int16_t min;
-
39  int16_t max;
- -
41 
- - - -
45 
-
51 bool gui_numupdown_add(NUMUPDOWN_STRUCT* numupdown);
-
52 
-
57 void gui_numupdown_remove(NUMUPDOWN_STRUCT* numupdown);
-
58 
-
63 void gui_numupdown_update(NUMUPDOWN_STRUCT* numupdown);
-
64 
-
69 void gui_numupdown_redraw(NUMUPDOWN_STRUCT* numupdown);
-
70 
-
73 #endif /* NUMUPDOWN_H */
-
uint16_t x
The x-Coordinate of the Top-Left Starting Point.
Definition: numupdown.h:34
-
Definition: button.h:37
-
NUMUPDOWN_CALLBACK callback
Callback which is executed when the value changes.
Definition: numupdown.h:40
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/gui/numupdown.h
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-04-30 timolang@gmail.com 76ea9d8 Added num up down support.
+
11 * 2015-05-11 timolang@gmail.com 08d9fe0 More work on doxygen module structure
+
12 * 2015-05-15 timolang@gmail.com 9a16865 Added doxgen comments to filesyste, checkbox, numupdown and screen module. And some minor changes to the other modules.
+
13 *
+
14 **************************************************************************************************************************************/
+
15 
+
16 #ifndef NUMUPDOWN_H
+
17 #define NUMUPDOWN_H
+
18 
+
19 #include "button.h"
+
20 
+
25 
+
31 
+
36 
+
43 typedef void (*NUMUPDOWN_CALLBACK)(void* numupdown, int16_t value);
+
44 
+
48 typedef struct {
+
49  uint16_t x;
+
50  uint16_t y;
+
51  uint16_t fgcolor;
+
52  int16_t value;
+
53  int16_t min;
+
54  int16_t max;
+ +
56 
+ + + +
60 
+
66 bool gui_numupdown_add(NUMUPDOWN_STRUCT* numupdown);
+
67 
+
72 void gui_numupdown_remove(NUMUPDOWN_STRUCT* numupdown);
+
73 
+
78 void gui_numupdown_update(NUMUPDOWN_STRUCT* numupdown);
+
79 
+
84 void gui_numupdown_redraw(NUMUPDOWN_STRUCT* numupdown);
+
85 
+
88 #endif /* NUMUPDOWN_H */
+
uint16_t x
The x-Coordinate of the Top-Left Starting Point.
Definition: numupdown.h:49
+ +
NUMUPDOWN_CALLBACK callback
Callback which is executed when the value changes.
Definition: numupdown.h:55
-
uint16_t y
The y-Coordinate of the Top-Left Starting Point.
Definition: numupdown.h:35
-
int16_t max
The maximum possible value (inclusive)
Definition: numupdown.h:39
-
Definition: numupdown.h:33
-
void(* NUMUPDOWN_CALLBACK)(void *numupdown, int16_t value)
Definition: numupdown.h:28
-
void gui_numupdown_remove(NUMUPDOWN_STRUCT *numupdown)
Definition: numupdown.c:112
-
int16_t min
The minimum possible value (inclusive)
Definition: numupdown.h:38
-
void gui_numupdown_redraw(NUMUPDOWN_STRUCT *numupdown)
Definition: numupdown.c:120
-
uint16_t fgcolor
The 16-bit color of the value-text.
Definition: numupdown.h:36
-
BUTTON_STRUCT buttonDown
For internal use, don't change, don't initialize.
Definition: numupdown.h:43
-
void gui_numupdown_update(NUMUPDOWN_STRUCT *numupdown)
Definition: numupdown.c:130
-
int16_t value
The current/default value.
Definition: numupdown.h:37
-
BUTTON_STRUCT buttonUp
For internal use, don't change, don't initialize.
Definition: numupdown.h:42
-
bool gui_numupdown_add(NUMUPDOWN_STRUCT *numupdown)
Definition: numupdown.c:59
+
uint16_t y
The y-Coordinate of the Top-Left Starting Point.
Definition: numupdown.h:50
+
int16_t max
The maximum possible value (inclusive)
Definition: numupdown.h:54
+ +
void(* NUMUPDOWN_CALLBACK)(void *numupdown, int16_t value)
Definition: numupdown.h:43
+
void gui_numupdown_remove(NUMUPDOWN_STRUCT *numupdown)
Definition: numupdown.c:136
+
int16_t min
The minimum possible value (inclusive)
Definition: numupdown.h:53
+
void gui_numupdown_redraw(NUMUPDOWN_STRUCT *numupdown)
Definition: numupdown.c:144
+
uint16_t fgcolor
The 16-bit color of the value-text.
Definition: numupdown.h:51
+
BUTTON_STRUCT buttonDown
For internal use, don't change, don't initialize.
Definition: numupdown.h:58
+
void gui_numupdown_update(NUMUPDOWN_STRUCT *numupdown)
Definition: numupdown.c:154
+
int16_t value
The current/default value.
Definition: numupdown.h:52
+
BUTTON_STRUCT buttonUp
For internal use, don't change, don't initialize.
Definition: numupdown.h:57
+
bool gui_numupdown_add(NUMUPDOWN_STRUCT *numupdown)
Definition: numupdown.c:80
diff --git a/pixy_8h.html b/pixy_8h.html index c71c3c9..a19362f 100644 --- a/pixy_8h.html +++ b/pixy_8h.html @@ -217,7 +217,7 @@ Functions
diff --git a/pixy_8h_source.html b/pixy_8h_source.html index 6da1184..45656e8 100644 --- a/pixy_8h_source.html +++ b/pixy_8h_source.html @@ -229,7 +229,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
int pixy_get_firmware_version(uint16_t *major, uint16_t *minor, uint16_t *build)
Get pixy firmware version.
int pixy_rcs_set_frequency(uint16_t frequency)
Set pixy servo pulse width modulation (PWM) frequency.
int pixy_cam_set_white_balance_value(uint8_t red, uint8_t green, uint8_t blue)
Set pixy camera white balance.
-
uint16_t y
Definition: pixy.h:81
+
uint16_t y
Definition: pixy.h:81
int pixy_cam_get_auto_exposure_compensation()
Get pixy camera auto exposure compensation setting.
int pixy_rcs_get_position(uint8_t channel)
Get pixy servo axis position.
int pixy_blocks_are_new()
Indicates when new block data from Pixy is received.
@@ -237,31 +237,31 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
int pixy_service()
int pixy_command(const char *name,...)
Send a command to Pixy.
int pixy_cam_set_exposure_compensation(uint8_t gain, uint16_t comp)
Set pixy camera exposure compensation.
-
uint16_t type
Definition: pixy.h:78
-
uint16_t height
Definition: pixy.h:83
+
uint16_t type
Definition: pixy.h:78
+
uint16_t height
Definition: pixy.h:83
int pixy_led_set_max_current(uint32_t current)
Set pixy LED maximum current.
int pixy_cam_set_auto_white_balance(uint8_t value)
Enable or disable pixy camera auto white balance.
int pixy_cam_set_auto_exposure_compensation(uint8_t enable)
Enable or disable pixy camera auto exposure compensation.
int pixy_init()
Creates a connection with Pixy and listens for Pixy messages.
-
uint16_t width
Definition: pixy.h:82
+
uint16_t width
Definition: pixy.h:82
int pixy_rcs_set_position(uint8_t channel, uint16_t position)
Set pixy servo axis position.
void pixy_error(int error_code)
Send description of pixy error to stdout.
-
uint16_t signature
Definition: pixy.h:79
+
uint16_t signature
Definition: pixy.h:79
void pixy_close()
Terminates connection with Pixy.
int pixy_cam_get_exposure_compensation(uint8_t *gain, uint16_t *comp)
Get pixy camera exposure compensation.
int pixy_get_blocks(uint16_t max_blocks, struct Block *blocks)
Copies up to 'max_blocks' number of Blocks to the address pointed to by 'blocks'. ...
int pixy_led_set_RGB(uint8_t red, uint8_t green, uint8_t blue)
Set color of pixy LED.
-
uint16_t x
Definition: pixy.h:80
+
uint16_t x
Definition: pixy.h:80
uint32_t pixy_cam_get_white_balance_value()
Get pixy camera white balance()
-
Definition: pixy.h:53
+
Definition: pixy.h:53
int pixy_cam_get_auto_white_balance()
Get pixy camera auto white balance setting.
int pixy_led_get_max_current()
Get pixy LED maximum current.
-
int16_t angle
Definition: pixy.h:84
+
int16_t angle
Definition: pixy.h:84
diff --git a/pixy__control_8c.html b/pixy__control_8c.html index e11ad24..1ff0b80 100644 --- a/pixy__control_8c.html +++ b/pixy__control_8c.html @@ -101,7 +101,9 @@ Include dependency graph for pixy_control.c: - + +

Go to the source code of this file.

+
@@ -131,6 +133,8 @@ Functions

Macros

#define REG_PID_KP   (0.5f)
+

Definition at line 39 of file pixy_control.c.

+
@@ -143,6 +147,8 @@ Functions
+

Definition at line 38 of file pixy_control.c.

+
@@ -155,6 +161,8 @@ Functions
+

Definition at line 37 of file pixy_control.c.

+
@@ -167,12 +175,14 @@ Functions
+

Definition at line 40 of file pixy_control.c.

+
diff --git a/pixy__control_8c_source.html b/pixy__control_8c_source.html new file mode 100644 index 0000000..ec86a03 --- /dev/null +++ b/pixy__control_8c_source.html @@ -0,0 +1,194 @@ + + + + + + +discoverpixy: common/app/pixy_control.c Source File + + + + + + + + + + +
+
+ + + + + + +
+
discoverpixy +
+
+
+ + + + + + +
+
+ + +
+ +
+ + +
+
+
+
pixy_control.c
+
+
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/app/pixy_control.c
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-06-02 aaron@duckpond.ch e018a75 Implemented basic pi and pid controller
+
11 * 2015-06-06 aaron@duckpond.ch 8c264c2 Comment refactoring, updated PID values
+
12 * 2015-06-06 aaron@duckpond.ch a04cda9 Refactured comments and implemented a bugfix for the PID controller
+
13 * 2015-06-07 aaron@duckpond.ch 802d3df Fixed pid controller and refactored code
+
14 * 2015-06-07 aaron@duckpond.ch 3d98ca9 Minor changes
+
15 * 2015-06-07 timolang@gmail.com c87220d Renamed pixy_helper to pixy_frame. Updated docu of appliaction. added doxygen comments to pixy_{frame,control}.h
+
16 *
+
17 **************************************************************************************************************************************/
+
18 
+
19 /*
+
20  * pixy_control.c
+
21  *
+
22  * Notation
+
23  * --------
+
24  *
+
25  * x : Sollwert (Führgrösse)
+
26  * w : Istwert (Reglergrösse)
+
27  * esum : Integralteil
+
28  * e : Regelabweichung
+
29  * y : Stellgrösse
+
30  *
+
31  *
+
32  */
+
33 #include<pixy_control.h>
+
34 #include<stdint.h>
+
35 
+
36 // PID tuning factors
+
37 #define REG_PID_KP (0.5f)
+
38 #define REG_PID_KI (0.001f)
+
39 #define REG_PID_KD (0.001f)
+
40 #define REG_PID_TA (0.01f)
+
41 
+
42 
+
43 // PID controller implementatoin for the y-axis
+
44 int16_t pixy_PID_Y(int16_t x, int16_t w)
+
45 {
+
46  float e = 0;
+
47  static float esum = 0;
+
48  static float eold = 0;
+
49  float y = 0;
+
50 
+
51  e = (float)(x - w); // calculate the controller offset
+
52 
+
53  //----PID-control-------------------------------------------------------------------------
+
54  esum = esum + e; // add e to the current sum
+
55 
+
56  y += REG_PID_KP * e; // add the proportional part to the output
+
57  y += REG_PID_KI * REG_PID_TA * esum; // add the integral part to the output
+
58  y += REG_PID_KD * (e - eold) / REG_PID_TA; // add the differential part to the output
+
59  //----------------------------------------------------------------------------------------
+
60 
+
61  eold = e; // save the previous value
+
62 
+
63  return (int16_t)y;
+
64 }
+
65 
+
66 // PID controller implementation for the x-axis
+
67 int16_t pixy_PID_X(int16_t x, int16_t w)
+
68 {
+
69  float e = 0;
+
70  static float esum = 0;
+
71  static float eold = 0;
+
72  float y = 0;
+
73 
+
74  e = (float)(x - w); // calculate the controller offset
+
75 
+
76  //----PID-control-------------------------------------------------------------------------
+
77  esum = esum + e; // add e to the current sum
+
78 
+
79  y += REG_PID_KP * e; // add the proportional part to the output
+
80  y += REG_PID_KI * REG_PID_TA * esum; // add the integral part to the output
+
81  y += REG_PID_KD * (e - eold) / REG_PID_TA; // add the differential part to the output
+
82  //----------------------------------------------------------------------------------------
+
83 
+
84  eold = e; // save the previous value
+
85 
+
86  return (int16_t)y;
+
87 }
+
#define REG_PID_KI
Definition: pixy_control.c:38
+
#define REG_PID_KP
Definition: pixy_control.c:37
+
#define REG_PID_TA
Definition: pixy_control.c:40
+ +
int16_t pixy_PID_X(int16_t x, int16_t w)
Definition: pixy_control.c:67
+
int16_t pixy_PID_Y(int16_t x, int16_t w)
Definition: pixy_control.c:44
+
#define REG_PID_KD
Definition: pixy_control.c:39
+
+ + + + diff --git a/pixy__control_8h.html b/pixy__control_8h.html index 4e4d0db..36df8e0 100644 --- a/pixy__control_8h.html +++ b/pixy__control_8h.html @@ -117,7 +117,7 @@ Functions diff --git a/pixy__control_8h_source.html b/pixy__control_8h_source.html index 39c12d8..355fa86 100644 --- a/pixy__control_8h_source.html +++ b/pixy__control_8h_source.html @@ -89,26 +89,43 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
pixy_control.h
-Go to the documentation of this file.
1 #ifndef PIXY_CONTROL_H_
-
2 #define PIXY_CONTROL_H_
-
3 
-
4 #include<stdint.h>
-
5 
-
10 
-
16 
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/app/pixy_control.h
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-06-02 aaron@duckpond.ch e018a75 Implemented basic pi and pid controller
+
11 * 2015-06-06 aaron@duckpond.ch 8c264c2 Comment refactoring, updated PID values
+
12 * 2015-06-06 aaron@duckpond.ch a04cda9 Refactured comments and implemented a bugfix for the PID controller
+
13 * 2015-06-07 aaron@duckpond.ch 802d3df Fixed pid controller and refactored code
+
14 * 2015-06-07 timolang@gmail.com c87220d Renamed pixy_helper to pixy_frame. Updated docu of appliaction. added doxygen comments to pixy_{frame,control}.h
+
15 *
+
16 **************************************************************************************************************************************/
17 
+
18 #ifndef PIXY_CONTROL_H_
+
19 #define PIXY_CONTROL_H_
+
20 
+
21 #include<stdint.h>
22 
-
29 int16_t pixy_PID_Y(int16_t x, int16_t w);
-
30 
-
37 int16_t pixy_PID_X(int16_t x, int16_t w);
-
38 
-
41 #endif /* PIXY_CONTROL_H_ */
-
int16_t pixy_PID_X(int16_t x, int16_t w)
Definition: pixy_control.c:49
-
int16_t pixy_PID_Y(int16_t x, int16_t w)
Definition: pixy_control.c:26
+
27 
+
33 
+
34 
+
39 
+
46 int16_t pixy_PID_Y(int16_t x, int16_t w);
+
47 
+
54 int16_t pixy_PID_X(int16_t x, int16_t w);
+
55 
+
58 #endif /* PIXY_CONTROL_H_ */
+
int16_t pixy_PID_X(int16_t x, int16_t w)
Definition: pixy_control.c:67
+
int16_t pixy_PID_Y(int16_t x, int16_t w)
Definition: pixy_control.c:44
diff --git a/pixy__frame_8c.html b/pixy__frame_8c.html index 319293a..7dc42b7 100644 --- a/pixy__frame_8c.html +++ b/pixy__frame_8c.html @@ -102,7 +102,9 @@ Include dependency graph for pixy_frame.c:
- + +

Go to the source code of this file.

+
@@ -185,6 +187,32 @@ Functions

Functions

static int renderBA81 (uint16_t xpos, uint16_t ypos, uint16_t width, uint16_t height, uint32_t frameLen, uint8_t *frame)
+

Definition at line 108 of file pixy_frame.c.

+
109 {
+
110  if (y & 1) {
+
111  if (x & 1) {
+
112  *r = *pixel;
+
113  *g = (*(pixel - 1) + * (pixel + 1) + * (pixel + width) + * (pixel - width)) >> 2;
+
114  *b = (*(pixel - width - 1) + * (pixel - width + 1) + * (pixel + width - 1) + * (pixel + width + 1)) >> 2;
+
115  } else {
+
116  *r = (*(pixel - 1) + * (pixel + 1)) >> 1;
+
117  *g = *pixel;
+
118  *b = (*(pixel - width) + * (pixel + width)) >> 1;
+
119  }
+
120  } else {
+
121  if (x & 1) {
+
122  *r = (*(pixel - width) + * (pixel + width)) >> 1;
+
123  *g = *pixel;
+
124  *b = (*(pixel - 1) + * (pixel + 1)) >> 1;
+
125  } else {
+
126  *r = (*(pixel - width - 1) + * (pixel - width + 1) + * (pixel + width - 1) + * (pixel + width + 1)) >> 2;
+
127  *g = (*(pixel - 1) + * (pixel + 1) + * (pixel + width) + * (pixel - width)) >> 2;
+
128  *b = *pixel;
+
129  }
+
130  }
+
131 
+
132 }
+

Here is the caller graph for this function:
@@ -252,6 +280,60 @@ Here is the caller graph for this function:
+

Definition at line 139 of file pixy_frame.c.

+
140 {
+
141  uint16_t x, y;
+
142  uint8_t r, g, b;
+
143 
+
144 
+
145  // skip first line
+
146  frame += width;
+
147 
+
148  // don't render top and bottom rows, and left and rightmost columns because of color
+
149  // interpolation
+
150  //uint32_t decodedimage[(width-2)*(height-2)];
+
151  uint16_t* decodedimage = malloc(sizeof(uint16_t) * (width - 2) * (height - 2));
+
152 
+
153  if (decodedimage == NULL) { //not enough free space to decode image in memory
+
154  //decode & render image pixel by pixel
+
155  for (y = 1; y < height - 1; y++) {
+
156  frame++;
+
157 
+
158  for (x = 1; x < width - 1; x++, frame++) {
+
159  interpolateBayer(width, x, y, frame, &r, &g, &b);
+
160  tft_draw_pixel(xpos + x - 1, ypos + y - 1, RGB(r, g, b));
+
161  }
+
162 
+
163  frame++;
+
164  }
+
165  } else { //enough space
+
166  uint16_t* line = decodedimage;
+
167 
+
168  for (y = 1; y < height - 1; y++) {
+
169  //line = (unsigned int *)img.scanLine(y-1);
+
170  frame++;
+
171 
+
172  for (x = 1; x < width - 1; x++, frame++) {
+
173  interpolateBayer(width, x, y, frame, &r, &g, &b);
+
174  //*line++ = (0xff<<24) | (r<<16) | (g<<8) | (b<<0);
+
175  *line++ = RGB(r, g, b);
+
176  }
+
177 
+
178  frame++;
+
179  }
+
180 
+
181  tft_draw_bitmap_unscaled(xpos, ypos, width - 2, height - 2, decodedimage);
+
182 
+
183  free(decodedimage);
+
184  }
+
185 
+
186  return 0;
+
187 }
+
#define RGB(r, g, b)
Definition: tft.h:48
+
void tft_draw_bitmap_unscaled(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint16_t *dat)
Definition: tft.c:72
+
static void interpolateBayer(uint16_t width, uint16_t x, uint16_t y, uint8_t *pixel, uint8_t *r, uint8_t *g, uint8_t *b)
Definition: pixy_frame.c:108
+
void tft_draw_pixel(uint16_t x, uint16_t y, uint16_t color)
Definition: tft.c:56
+

Here is the call graph for this function:
@@ -322,6 +404,54 @@ Here is the caller graph for this function:
+

Definition at line 189 of file pixy_frame.c.

+
190 {
+
191  uint16_t x, y;
+
192  uint8_t r, g, b;
+
193 
+
194  uint32_t fpos = handle->fpos;
+
195  uint32_t row_size_padded = ((width - 2) * 3 + 3) & (~3); //row size aligned to 4 bytes
+
196  uint32_t fpos_end = fpos + row_size_padded * (height - 2);
+
197 
+
198 
+
199  // skip first line
+
200  frame += width;
+
201 
+
202  // don't render top and bottom rows, and left and rightmost columns because of color
+
203  // interpolation
+
204 
+
205  for (y = 1; y < height - 1; y++) {
+
206  frame++;
+
207  uint8_t rowbuf[row_size_padded];
+
208 
+
209  //Bitmaps are saved "bottom-up". Seek to the right row.
+
210  if (filesystem_file_seek(handle, fpos_end - row_size_padded * y) != F_OK) {
+
211  return -1;
+
212  }
+
213 
+
214  for (x = 1; x < width - 1; x++, frame++) {
+
215  interpolateBayer(width, x, y, frame, &r, &g, &b);
+
216  //bitmaps are saved in 24bit b,g,r format
+
217  rowbuf[(x - 1) * 3] = b;
+
218  rowbuf[(x - 1) * 3 + 1] = g;
+
219  rowbuf[(x - 1) * 3 + 2] = r;
+
220  }
+
221 
+
222  if (filesystem_file_write(handle, rowbuf, row_size_padded) != F_OK) {
+
223  return -1;
+
224  }
+
225 
+
226  frame++;
+
227  }
+
228 
+
229  return 0;
+
230 }
+
FILE_STATUS filesystem_file_seek(FILE_HANDLE *handle, uint32_t offset)
Definition: filesystem.c:43
+
static void interpolateBayer(uint16_t width, uint16_t x, uint16_t y, uint8_t *pixel, uint8_t *r, uint8_t *g, uint8_t *b)
Definition: pixy_frame.c:108
+
FILE_STATUS filesystem_file_write(FILE_HANDLE *handle, uint8_t *buf, uint32_t size)
Definition: filesystem.c:53
+
uint32_t fpos
The current byte-position in the file.
Definition: filesystem.h:83
+
Everything ok.
Definition: filesystem.h:91
+

Here is the call graph for this function:
@@ -345,7 +475,7 @@ Here is the caller graph for this function:
diff --git a/pixy__frame_8c_source.html b/pixy__frame_8c_source.html new file mode 100644 index 0000000..f4be5db --- /dev/null +++ b/pixy__frame_8c_source.html @@ -0,0 +1,373 @@ + + + + + + +discoverpixy: common/app/pixy_frame.c Source File + + + + + + + + + + +
+
+ + + + + + +
+
discoverpixy +
+
+
+ + + + + + +
+
+ + +
+ +
+ + +
+
+
+
pixy_frame.c
+
+
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/app/pixy_frame.c
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-06-07 timolang@gmail.com c87220d Renamed pixy_helper to pixy_frame. Updated docu of appliaction. added doxygen comments to pixy_{frame,control}.h
+
11 *
+
12 **************************************************************************************************************************************/
+
13 
+
14 #include "pixy_frame.h"
+
15 #include "pixy.h"
+
16 #include "tft.h"
+
17 #include <stdlib.h>
+
18 
+
19 
+
20 
+
21 static int renderBA81(uint16_t xpos, uint16_t ypos, uint16_t width, uint16_t height, uint32_t frameLen, uint8_t* frame);
+
22 static int saveBA81(FILE_HANDLE* handle, uint16_t width, uint16_t height, uint32_t frameLen, uint8_t* frame);
+
23 
+
24 
+
25 int pixy_render_full_frame(uint16_t x, uint16_t y)
+
26 {
+
27  return pixy_render_cropped_frame(x, y, 0, 0, 320, 200);
+
28 }
+
29 
+
30 
+
31 int pixy_render_cropped_frame(uint16_t x, uint16_t y, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
+
32 {
+
33  uint8_t* videodata;
+
34  int32_t response;
+
35  int32_t fourccc;
+
36  int8_t renderflags;
+
37  uint16_t xwidth;
+
38  uint16_t ywidth;
+
39  uint32_t size;
+
40 
+
41 
+
42  int return_value = pixy_command("cam_getFrame", // String id for remote procedure
+
43  INT8(0x21), // mode
+
44  INT16(xoffset), // xoffset
+
45  INT16(yoffset), // yoffset
+
46  INT16(width), // width
+
47  INT16(height), // height
+
48  END_OUT_ARGS, // separator
+
49  &response, // pointer to mem address for return value
+
50  &fourccc,
+
51  &renderflags,
+
52  &xwidth,
+
53  &ywidth,
+
54  &size,
+
55  &videodata, // pointer to mem address for returned frame
+
56  END_IN_ARGS);
+
57 
+
58  if (return_value == 0) {
+
59  return_value = renderBA81(x, y, xwidth, ywidth, size, videodata);
+
60  }
+
61 
+
62  return return_value;
+
63 }
+
64 
+ +
66 {
+
67  return pixy_save_cropped_frame(handle, 0, 0, 320, 200);
+
68 }
+
69 
+
70 int pixy_save_cropped_frame(FILE_HANDLE* handle, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
+
71 {
+
72  uint8_t* videodata;
+
73  int32_t response;
+
74  int32_t fourccc;
+
75  int8_t renderflags;
+
76  uint16_t xwidth;
+
77  uint16_t ywidth;
+
78  uint32_t size;
+
79 
+
80 
+
81  int return_value = pixy_command("cam_getFrame", // String id for remote procedure
+
82  INT8(0x21), // mode
+
83  INT16(xoffset), // xoffset
+
84  INT16(yoffset), // yoffset
+
85  INT16(width), // width
+
86  INT16(height), // height
+
87  END_OUT_ARGS, // separator
+
88  &response, // pointer to mem address for return value
+
89  &fourccc,
+
90  &renderflags,
+
91  &xwidth,
+
92  &ywidth,
+
93  &size,
+
94  &videodata, // pointer to mem address for returned frame
+
95  END_IN_ARGS);
+
96 
+
97  if (return_value == 0) {
+
98  return_value = saveBA81(handle, xwidth, ywidth, size, videodata);
+
99  }
+
100 
+
101  return return_value;
+
102 }
+
103 
+
104 
+
105 
+
106 
+
107 
+
108 static void interpolateBayer(uint16_t width, uint16_t x, uint16_t y, uint8_t* pixel, uint8_t* r, uint8_t* g, uint8_t* b)
+
109 {
+
110  if (y & 1) {
+
111  if (x & 1) {
+
112  *r = *pixel;
+
113  *g = (*(pixel - 1) + * (pixel + 1) + * (pixel + width) + * (pixel - width)) >> 2;
+
114  *b = (*(pixel - width - 1) + * (pixel - width + 1) + * (pixel + width - 1) + * (pixel + width + 1)) >> 2;
+
115  } else {
+
116  *r = (*(pixel - 1) + * (pixel + 1)) >> 1;
+
117  *g = *pixel;
+
118  *b = (*(pixel - width) + * (pixel + width)) >> 1;
+
119  }
+
120  } else {
+
121  if (x & 1) {
+
122  *r = (*(pixel - width) + * (pixel + width)) >> 1;
+
123  *g = *pixel;
+
124  *b = (*(pixel - 1) + * (pixel + 1)) >> 1;
+
125  } else {
+
126  *r = (*(pixel - width - 1) + * (pixel - width + 1) + * (pixel + width - 1) + * (pixel + width + 1)) >> 2;
+
127  *g = (*(pixel - 1) + * (pixel + 1) + * (pixel + width) + * (pixel - width)) >> 2;
+
128  *b = *pixel;
+
129  }
+
130  }
+
131 
+
132 }
+
133 
+
134 
+
135 
+
136 
+
137 
+
138 
+
139 static int renderBA81(uint16_t xpos, uint16_t ypos, uint16_t width, uint16_t height, uint32_t frameLen, uint8_t* frame)
+
140 {
+
141  uint16_t x, y;
+
142  uint8_t r, g, b;
+
143 
+
144 
+
145  // skip first line
+
146  frame += width;
+
147 
+
148  // don't render top and bottom rows, and left and rightmost columns because of color
+
149  // interpolation
+
150  //uint32_t decodedimage[(width-2)*(height-2)];
+
151  uint16_t* decodedimage = malloc(sizeof(uint16_t) * (width - 2) * (height - 2));
+
152 
+
153  if (decodedimage == NULL) { //not enough free space to decode image in memory
+
154  //decode & render image pixel by pixel
+
155  for (y = 1; y < height - 1; y++) {
+
156  frame++;
+
157 
+
158  for (x = 1; x < width - 1; x++, frame++) {
+
159  interpolateBayer(width, x, y, frame, &r, &g, &b);
+
160  tft_draw_pixel(xpos + x - 1, ypos + y - 1, RGB(r, g, b));
+
161  }
+
162 
+
163  frame++;
+
164  }
+
165  } else { //enough space
+
166  uint16_t* line = decodedimage;
+
167 
+
168  for (y = 1; y < height - 1; y++) {
+
169  //line = (unsigned int *)img.scanLine(y-1);
+
170  frame++;
+
171 
+
172  for (x = 1; x < width - 1; x++, frame++) {
+
173  interpolateBayer(width, x, y, frame, &r, &g, &b);
+
174  //*line++ = (0xff<<24) | (r<<16) | (g<<8) | (b<<0);
+
175  *line++ = RGB(r, g, b);
+
176  }
+
177 
+
178  frame++;
+
179  }
+
180 
+
181  tft_draw_bitmap_unscaled(xpos, ypos, width - 2, height - 2, decodedimage);
+
182 
+
183  free(decodedimage);
+
184  }
+
185 
+
186  return 0;
+
187 }
+
188 
+
189 static int saveBA81(FILE_HANDLE* handle, uint16_t width, uint16_t height, uint32_t frameLen, uint8_t* frame)
+
190 {
+
191  uint16_t x, y;
+
192  uint8_t r, g, b;
+
193 
+
194  uint32_t fpos = handle->fpos;
+
195  uint32_t row_size_padded = ((width - 2) * 3 + 3) & (~3); //row size aligned to 4 bytes
+
196  uint32_t fpos_end = fpos + row_size_padded * (height - 2);
+
197 
+
198 
+
199  // skip first line
+
200  frame += width;
+
201 
+
202  // don't render top and bottom rows, and left and rightmost columns because of color
+
203  // interpolation
+
204 
+
205  for (y = 1; y < height - 1; y++) {
+
206  frame++;
+
207  uint8_t rowbuf[row_size_padded];
+
208 
+
209  //Bitmaps are saved "bottom-up". Seek to the right row.
+
210  if (filesystem_file_seek(handle, fpos_end - row_size_padded * y) != F_OK) {
+
211  return -1;
+
212  }
+
213 
+
214  for (x = 1; x < width - 1; x++, frame++) {
+
215  interpolateBayer(width, x, y, frame, &r, &g, &b);
+
216  //bitmaps are saved in 24bit b,g,r format
+
217  rowbuf[(x - 1) * 3] = b;
+
218  rowbuf[(x - 1) * 3 + 1] = g;
+
219  rowbuf[(x - 1) * 3 + 2] = r;
+
220  }
+
221 
+
222  if (filesystem_file_write(handle, rowbuf, row_size_padded) != F_OK) {
+
223  return -1;
+
224  }
+
225 
+
226  frame++;
+
227  }
+
228 
+
229  return 0;
+
230 }
+
231 
+
232 
+
233 int pixy_cc_set_region(uint8_t signum, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
+
234 {
+
235  int32_t response;
+
236 
+
237  int return_value = pixy_command("cc_setSigRegion", // String id for remote procedure
+
238  INT32(0), // type = normal color code
+
239  INT8(signum),
+
240  INT16(xoffset), // xoffset
+
241  INT16(yoffset), // yoffset
+
242  INT16(width), // width
+
243  INT16(height), // height
+
244  END_OUT_ARGS, // separator
+
245  &response, // pointer to mem address for return value
+
246  END_IN_ARGS);
+
247  return return_value;
+
248 }
+
FILE_STATUS filesystem_file_seek(FILE_HANDLE *handle, uint32_t offset)
Definition: filesystem.c:43
+
static int renderBA81(uint16_t xpos, uint16_t ypos, uint16_t width, uint16_t height, uint32_t frameLen, uint8_t *frame)
Definition: pixy_frame.c:139
+
static int saveBA81(FILE_HANDLE *handle, uint16_t width, uint16_t height, uint32_t frameLen, uint8_t *frame)
Definition: pixy_frame.c:189
+
#define RGB(r, g, b)
Definition: tft.h:48
+
#define INT16(v)
Definition: pixydefs.h:63
+
#define INT32(v)
Definition: pixydefs.h:65
+ +
int pixy_save_cropped_frame(FILE_HANDLE *handle, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
Definition: pixy_frame.c:70
+
int pixy_save_full_frame(FILE_HANDLE *handle)
Definition: pixy_frame.c:65
+
int pixy_render_cropped_frame(uint16_t x, uint16_t y, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
Definition: pixy_frame.c:31
+
void tft_draw_bitmap_unscaled(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint16_t *dat)
Definition: tft.c:72
+
static void interpolateBayer(uint16_t width, uint16_t x, uint16_t y, uint8_t *pixel, uint8_t *r, uint8_t *g, uint8_t *b)
Definition: pixy_frame.c:108
+
void tft_draw_pixel(uint16_t x, uint16_t y, uint16_t color)
Definition: tft.c:56
+ +
int pixy_command(const char *name,...)
Send a command to Pixy.
+ +
FILE_STATUS filesystem_file_write(FILE_HANDLE *handle, uint8_t *buf, uint32_t size)
Definition: filesystem.c:53
+
uint32_t fpos
The current byte-position in the file.
Definition: filesystem.h:83
+ +
#define END_OUT_ARGS
Definition: pixydefs.h:89
+
Everything ok.
Definition: filesystem.h:91
+
int pixy_render_full_frame(uint16_t x, uint16_t y)
Definition: pixy_frame.c:25
+
int pixy_cc_set_region(uint8_t signum, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
Definition: pixy_frame.c:233
+
#define END_IN_ARGS
Definition: pixydefs.h:90
+
#define INT8(v)
Definition: pixydefs.h:61
+
+ + + + diff --git a/pixy__frame_8h.html b/pixy__frame_8h.html index 24ad922..b52cf32 100644 --- a/pixy__frame_8h.html +++ b/pixy__frame_8h.html @@ -127,7 +127,7 @@ Functions diff --git a/pixy__frame_8h_source.html b/pixy__frame_8h_source.html index 0f61612..4fb80df 100644 --- a/pixy__frame_8h_source.html +++ b/pixy__frame_8h_source.html @@ -89,41 +89,54 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
pixy_frame.h
-Go to the documentation of this file.
1 #ifndef PIXY_FRAME_H
-
2 #define PIXY_FRAME_H
-
3 
-
4 #include <stdbool.h>
-
5 #include <stdint.h>
-
6 #include "filesystem.h"
-
7 
-
8 
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/app/pixy_frame.h
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-06-07 timolang@gmail.com c87220d Renamed pixy_helper to pixy_frame. Updated docu of appliaction. added doxygen comments to pixy_{frame,control}.h
+
11 *
+
12 **************************************************************************************************************************************/
13 
+
14 #ifndef PIXY_FRAME_H
+
15 #define PIXY_FRAME_H
+
16 
+
17 #include <stdbool.h>
+
18 #include <stdint.h>
+
19 #include "filesystem.h"
20 
21 
26 
-
27 
-
34 int pixy_render_full_frame(uint16_t x, uint16_t y);
-
35 
-
46 int pixy_render_cropped_frame(uint16_t x, uint16_t y, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height);
-
47 
- -
56 
-
66 int pixy_save_cropped_frame(FILE_HANDLE* handle, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height);
-
67 
-
77 int pixy_cc_set_region(uint8_t signum, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height);
-
78 
-
81 #endif /* PIXY_FRAME_H */
-
Definition: filesystem.h:66
-
int pixy_save_cropped_frame(FILE_HANDLE *handle, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
Definition: pixy_frame.c:54
-
int pixy_save_full_frame(FILE_HANDLE *handle)
Definition: pixy_frame.c:50
-
int pixy_render_cropped_frame(uint16_t x, uint16_t y, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
Definition: pixy_frame.c:17
+
33 
+
34 
+
39 
+
40 
+
47 int pixy_render_full_frame(uint16_t x, uint16_t y);
+
48 
+
59 int pixy_render_cropped_frame(uint16_t x, uint16_t y, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height);
+
60 
+ +
69 
+
79 int pixy_save_cropped_frame(FILE_HANDLE* handle, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height);
+
80 
+
90 int pixy_cc_set_region(uint8_t signum, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height);
+
91 
+
94 #endif /* PIXY_FRAME_H */
+ +
int pixy_save_cropped_frame(FILE_HANDLE *handle, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
Definition: pixy_frame.c:70
+
int pixy_save_full_frame(FILE_HANDLE *handle)
Definition: pixy_frame.c:65
+
int pixy_render_cropped_frame(uint16_t x, uint16_t y, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
Definition: pixy_frame.c:31
-
int pixy_render_full_frame(uint16_t x, uint16_t y)
Definition: pixy_frame.c:12
-
int pixy_cc_set_region(uint8_t signum, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
Definition: pixy_frame.c:225
+
int pixy_render_full_frame(uint16_t x, uint16_t y)
Definition: pixy_frame.c:25
+
int pixy_cc_set_region(uint8_t signum, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
Definition: pixy_frame.c:233
diff --git a/pixydefs_8h.html b/pixydefs_8h.html index 8bbcbcb..4d80d98 100644 --- a/pixydefs_8h.html +++ b/pixydefs_8h.html @@ -217,6 +217,8 @@ Macros
+

Definition at line 34 of file pixydefs.h.

+
@@ -229,6 +231,8 @@ Macros
+

Definition at line 35 of file pixydefs.h.

+
@@ -241,6 +245,8 @@ Macros
+

Definition at line 44 of file pixydefs.h.

+
@@ -253,6 +259,8 @@ Macros
+

Definition at line 45 of file pixydefs.h.

+
@@ -265,6 +273,8 @@ Macros
+

Definition at line 57 of file pixydefs.h.

+
@@ -277,6 +287,8 @@ Macros
+

Definition at line 58 of file pixydefs.h.

+
@@ -289,6 +301,8 @@ Macros
+

Definition at line 40 of file pixydefs.h.

+
@@ -301,6 +315,8 @@ Macros
+

Definition at line 42 of file pixydefs.h.

+
@@ -313,6 +329,8 @@ Macros
+

Definition at line 38 of file pixydefs.h.

+
@@ -325,6 +343,8 @@ Macros
+

Definition at line 49 of file pixydefs.h.

+
@@ -337,6 +357,8 @@ Macros
+

Definition at line 50 of file pixydefs.h.

+
@@ -349,6 +371,8 @@ Macros
+

Definition at line 48 of file pixydefs.h.

+
@@ -361,6 +385,8 @@ Macros
+

Definition at line 36 of file pixydefs.h.

+
@@ -373,6 +399,8 @@ Macros
+

Definition at line 37 of file pixydefs.h.

+
@@ -385,6 +413,8 @@ Macros
+

Definition at line 46 of file pixydefs.h.

+
@@ -397,6 +427,8 @@ Macros
+

Definition at line 47 of file pixydefs.h.

+
@@ -409,6 +441,8 @@ Macros
+

Definition at line 41 of file pixydefs.h.

+
@@ -421,6 +455,8 @@ Macros
+

Definition at line 43 of file pixydefs.h.

+
@@ -433,6 +469,8 @@ Macros
+

Definition at line 39 of file pixydefs.h.

+
@@ -445,6 +483,8 @@ Macros
+

Definition at line 55 of file pixydefs.h.

+
@@ -457,6 +497,8 @@ Macros
+

Definition at line 53 of file pixydefs.h.

+
@@ -469,6 +511,8 @@ Macros
+

Definition at line 56 of file pixydefs.h.

+
@@ -481,6 +525,8 @@ Macros
+

Definition at line 54 of file pixydefs.h.

+
@@ -493,6 +539,8 @@ Macros
+

Definition at line 51 of file pixydefs.h.

+
@@ -505,6 +553,8 @@ Macros
+

Definition at line 52 of file pixydefs.h.

+
@@ -517,6 +567,8 @@ Macros
+

Definition at line 86 of file pixydefs.h.

+
@@ -529,6 +581,8 @@ Macros
+

Definition at line 90 of file pixydefs.h.

+
@@ -541,6 +595,8 @@ Macros
+

Definition at line 89 of file pixydefs.h.

+
@@ -557,6 +613,8 @@ Macros
+

Definition at line 67 of file pixydefs.h.

+
@@ -573,6 +631,8 @@ Macros
+

Definition at line 68 of file pixydefs.h.

+
@@ -599,6 +659,8 @@ Macros
+

Definition at line 79 of file pixydefs.h.

+
@@ -625,6 +687,8 @@ Macros
+

Definition at line 80 of file pixydefs.h.

+
@@ -641,6 +705,8 @@ Macros
+

Definition at line 63 of file pixydefs.h.

+
@@ -657,6 +723,8 @@ Macros
+

Definition at line 65 of file pixydefs.h.

+
@@ -673,6 +741,8 @@ Macros
+

Definition at line 61 of file pixydefs.h.

+
@@ -699,6 +769,8 @@ Macros
+

Definition at line 75 of file pixydefs.h.

+
@@ -725,6 +797,8 @@ Macros
+

Definition at line 77 of file pixydefs.h.

+
@@ -751,6 +825,8 @@ Macros
+

Definition at line 70 of file pixydefs.h.

+
@@ -763,6 +839,8 @@ Macros
+

Definition at line 31 of file pixydefs.h.

+
@@ -775,6 +853,8 @@ Macros
+

Definition at line 32 of file pixydefs.h.

+
@@ -787,6 +867,8 @@ Macros
+

Definition at line 30 of file pixydefs.h.

+
@@ -803,6 +885,8 @@ Macros
+

Definition at line 69 of file pixydefs.h.

+
@@ -819,6 +903,8 @@ Macros
+

Definition at line 64 of file pixydefs.h.

+
@@ -835,6 +921,8 @@ Macros
+

Definition at line 66 of file pixydefs.h.

+
@@ -851,6 +939,8 @@ Macros
+

Definition at line 62 of file pixydefs.h.

+
@@ -877,6 +967,8 @@ Macros
+

Definition at line 76 of file pixydefs.h.

+
@@ -893,6 +985,8 @@ Macros
+

Definition at line 73 of file pixydefs.h.

+
@@ -919,6 +1013,8 @@ Macros
+

Definition at line 78 of file pixydefs.h.

+
@@ -935,6 +1031,8 @@ Macros
+

Definition at line 74 of file pixydefs.h.

+
@@ -961,6 +1059,8 @@ Macros
+

Definition at line 71 of file pixydefs.h.

+
@@ -977,12 +1077,14 @@ Macros
+

Definition at line 72 of file pixydefs.h.

+
diff --git a/pixydefs_8h_source.html b/pixydefs_8h_source.html index 91009c9..74f886f 100644 --- a/pixydefs_8h_source.html +++ b/pixydefs_8h_source.html @@ -184,7 +184,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/screen_8c.html b/screen_8c.html index 6cc852d..283b3a4 100644 --- a/screen_8c.html +++ b/screen_8c.html @@ -100,7 +100,9 @@ Include dependency graph for screen.c: - + +

Go to the source code of this file.

+
@@ -140,6 +142,8 @@ Variables

Functions

SCREEN_STRUCTgui_screen_get_current ()
+

Definition at line 32 of file screen.c.

+
@@ -160,6 +164,8 @@ Variables
+

Definition at line 33 of file screen.c.

+
@@ -180,12 +186,14 @@ Variables
+

Definition at line 31 of file screen.c.

+
diff --git a/screen_8c_source.html b/screen_8c_source.html new file mode 100644 index 0000000..57fbef3 --- /dev/null +++ b/screen_8c_source.html @@ -0,0 +1,224 @@ + + + + + + +discoverpixy: common/gui/screen.c Source File + + + + + + + + + + +
+
+ + + + + + +
+
discoverpixy +
+
+
+ + + + + + +
+
+ + +
+ +
+ + +
+
+
+
screen.c
+
+
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/gui/screen.c
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-04-27 timolang@gmail.com cf72baa Introduced a Screen (sub) module and divided app into multiple screens.
+
11 * 2015-04-27 timolang@gmail.com 77e6d0e Fixed screen implementation.
+
12 * 2015-05-10 timolang@gmail.com b6ab7c8 Fixed compiler warning in tft and screen module.
+
13 * 2015-05-17 timolang@gmail.com 2d46336 Improved comments in implementation of button, checkbox, numupdown, tft, touch and screen modules/submodules.
+
14 * 2015-06-01 timolang@gmail.com eb573bc Finalized calibration. Fixed a bug in screen module.
+
15 * 2015-06-06 timolang@gmail.com c06661d Fixed some outdated comments in source code. Documented Gui Module in docu.
+
16 *
+
17 **************************************************************************************************************************************/
+
18 
+
19 #include "screen.h"
+
20 
+
21 /* The idea is as follows:
+
22  * We only call screen callbacks from the gui_screen_update() method, which is called from the applications main loop.
+
23  * Instructions to switch the screen will be delayed until the gui_screen_update() method is called again.
+
24  * This makes it safe to change the screen from an touch interrupt (e.g. button callback)
+
25  */
+
26 
+
27 /* Possible Improvements:
+
28  * Ensure that you can not navigate to a screen which is already in the history (because it will corrupt the list)
+
29  */
+
30 
+
31 static SCREEN_STRUCT* screen_list = NULL; //Head of the linked list which stores the screen history.
+
32 static SCREEN_STRUCT* screen_current = NULL; //Pointer to the current screen (= tail of the list)
+
33 static volatile SCREEN_STRUCT* screen_goto = NULL; //Screen we should navigate to once we enter the gui_screen_update() method again
+
34 
+ +
36 {
+
37  return screen_current;
+
38 }
+
39 
+
40 
+ +
42 {
+
43  if (screen_goto != NULL) { //we received the task to switch the screen
+
44  SCREEN_STRUCT* go = (SCREEN_STRUCT*) screen_goto; //Backup volatile variable
+
45  screen_goto = NULL; //reset the "goto instruction", since we're processing it now
+
46 
+
47  if (go->next != NULL) { //The screen is not the last in the list, so we're going back
+
48  if (go->next != screen_current) { //this condition should always be false
+
49  return; //list corrupted?
+
50  }
+
51 
+
52  screen_current->on_leave(screen_current); //let the current screen free/unregister it's resources
+
53  go->next = NULL; //remove the current screen from the list
+
54  } else { //we're going forward (to a new screen)
+
55  if (screen_current != NULL) { //this is not the first screen
+
56  screen_current->on_leave(screen_current); //let the current screen free/unregister it's resources
+
57  screen_current->next = go; //append the new screen to the end of the list
+
58  } else { //first screen ever seen
+
59  screen_list = go; //set the new screen as list-head
+
60  }
+
61  }
+
62 
+
63  go->on_enter(go); //let the new screen allocate/register it's resources
+
64  screen_current = go; //the new screen is now the current screen. Transition done
+
65  }
+
66 
+
67  if (screen_current != NULL) { //A screen has been set
+
68  screen_current->on_update(screen_current); //Update current screen
+
69  }
+
70 }
+
71 
+
72 
+
73 
+ +
75 {
+
76  if (screen == NULL || screen == screen_current || screen == screen_goto) { //invalid argument passed
+
77  return false;
+
78  }
+
79 
+
80  screen->next = NULL; //this will become the new tail of the list, so the next pointer must be NULL
+
81  screen_goto = screen; //"send message" to main loop, to switch the screen
+
82  return true;
+
83 }
+
84 
+ +
86 {
+
87  if (screen_list == NULL) { //the list head is emtpy, nothing to go back to
+
88  return false;
+
89  }
+
90 
+
91  SCREEN_STRUCT* current = screen_list;
+
92  SCREEN_STRUCT* last = NULL;
+
93 
+
94  //Find second last element in list
+
95  while (current->next != NULL) {
+
96  last = current;
+
97  current = current->next;
+
98  }
+
99 
+
100  if (last == NULL) {
+
101  return false; //There's only a single screen, there's no going back here
+
102  }
+
103 
+
104  if (current != screen_current) {
+
105  return false; //The last entry in the list is not the current screen. List corrupted?
+
106  }
+
107 
+
108  screen_goto = last; //"send message" to main loop, to switch the screen
+
109  return true;
+
110 }
+
SCREEN_CALLBACK on_enter
The Callback which is called when the screen is entered. Add/Register all UI-Elements here...
Definition: screen.h:53
+
struct SCREEN_S * next
Used internally. do not modify, do not initialize.
Definition: screen.h:57
+ +
void gui_screen_update()
Definition: screen.c:41
+
static SCREEN_STRUCT * screen_current
Definition: screen.c:32
+
static volatile SCREEN_STRUCT * screen_goto
Definition: screen.c:33
+
static SCREEN_STRUCT * screen_list
Definition: screen.c:31
+
SCREEN_STRUCT * gui_screen_get_current()
Definition: screen.c:35
+
SCREEN_CALLBACK on_leave
The Callback which is called when the screen is left. Remove/Unregister all UI-Elements here...
Definition: screen.h:54
+
bool gui_screen_navigate(SCREEN_STRUCT *screen)
Definition: screen.c:74
+ +
static SCREEN_STRUCT screen
+
bool gui_screen_back()
Definition: screen.c:85
+
SCREEN_CALLBACK on_update
The Callback which is called repeatedly when the screen should be updated. Update/Redraw all UI-Eleme...
Definition: screen.h:55
+
+ + + + diff --git a/screen_8h.html b/screen_8h.html index 6ca20a2..f1feeae 100644 --- a/screen_8h.html +++ b/screen_8h.html @@ -136,7 +136,7 @@ Functions diff --git a/screen_8h_source.html b/screen_8h_source.html index d2b15e8..cde468f 100644 --- a/screen_8h_source.html +++ b/screen_8h_source.html @@ -89,54 +89,72 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
screen.h
-Go to the documentation of this file.
1 #ifndef SCREEN_H
-
2 #define SCREEN_H
-
3 
-
4 #include <stdio.h>
-
5 #include <stdbool.h>
-
6 
-
11 
-
19 
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/gui/screen.h
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-04-27 timolang@gmail.com cf72baa Introduced a Screen (sub) module and divided app into multiple screens.
+
11 * 2015-04-27 timolang@gmail.com 77e6d0e Fixed screen implementation.
+
12 * 2015-05-11 timolang@gmail.com 08d9fe0 More work on doxygen module structure
+
13 * 2015-05-15 timolang@gmail.com 9a16865 Added doxgen comments to filesyste, checkbox, numupdown and screen module. And some minor changes to the other modules.
+
14 * 2015-05-17 timolang@gmail.com 2d46336 Improved comments in implementation of button, checkbox, numupdown, tft, touch and screen modules/submodules.
+
15 * 2015-06-06 timolang@gmail.com c06661d Fixed some outdated comments in source code. Documented Gui Module in docu.
+
16 *
+
17 **************************************************************************************************************************************/
+
18 
+
19 #ifndef SCREEN_H
+
20 #define SCREEN_H
+
21 
+
22 #include <stdio.h>
+
23 #include <stdbool.h>
24 
-
29 typedef void (*SCREEN_CALLBACK)(void* screen);
-
30 
-
34 typedef struct SCREEN_S{
- - - -
38 
-
39  struct SCREEN_S* next;
- -
41 
+
29 
+
37 
42 
-
43 
- -
52 
-
58 bool gui_screen_back();
+
47 typedef void (*SCREEN_CALLBACK)(void* screen);
+
48 
+
52 typedef struct SCREEN_S {
+ + + +
56 
+
57  struct SCREEN_S* next;
+
59 
60 
- -
66 
-
67 //Updates/switches the screens. Call this from the app main loop, as fast as you can.
-
72 void gui_screen_update();
-
73 
-
76 #endif /* SCREEN_H */
+
61 
+ +
70 
+
76 bool gui_screen_back();
+
77 
+
78 
+ +
84 
+
85 //Updates/switches the screens. Call this from the app main loop, as fast as you can.
+
90 void gui_screen_update();
+
91 
+
94 #endif /* SCREEN_H */
struct SCREEN_S SCREEN_STRUCT
-
SCREEN_CALLBACK on_enter
The Callback which is called when the screen is entered. Add/Register all UI-Elements here...
Definition: screen.h:35
-
struct SCREEN_S * next
Used internally. do not modify, do not initialize.
Definition: screen.h:39
-
void gui_screen_update()
Definition: screen.c:22
-
SCREEN_STRUCT * gui_screen_get_current()
Definition: screen.c:17
-
SCREEN_CALLBACK on_leave
The Callback which is called when the screen is left. Remove/Unregister all UI-Elements here...
Definition: screen.h:36
-
bool gui_screen_navigate(SCREEN_STRUCT *screen)
Definition: screen.c:51
-
Definition: screen.h:34
-
static SCREEN_STRUCT screen
Definition: screen_filetest.c:121
-
void(* SCREEN_CALLBACK)(void *screen)
Definition: screen.h:29
-
bool gui_screen_back()
Definition: screen.c:60
-
SCREEN_CALLBACK on_update
The Callback which is called repeatedly when the screen should be updated. Update/Redraw all UI-Eleme...
Definition: screen.h:37
+
SCREEN_CALLBACK on_enter
The Callback which is called when the screen is entered. Add/Register all UI-Elements here...
Definition: screen.h:53
+
struct SCREEN_S * next
Used internally. do not modify, do not initialize.
Definition: screen.h:57
+
void gui_screen_update()
Definition: screen.c:41
+
SCREEN_STRUCT * gui_screen_get_current()
Definition: screen.c:35
+
SCREEN_CALLBACK on_leave
The Callback which is called when the screen is left. Remove/Unregister all UI-Elements here...
Definition: screen.h:54
+
bool gui_screen_navigate(SCREEN_STRUCT *screen)
Definition: screen.c:74
+ +
static SCREEN_STRUCT screen
+
void(* SCREEN_CALLBACK)(void *screen)
Definition: screen.h:47
+
bool gui_screen_back()
Definition: screen.c:85
+
SCREEN_CALLBACK on_update
The Callback which is called repeatedly when the screen should be updated. Update/Redraw all UI-Eleme...
Definition: screen.h:55
diff --git a/screen__calibrate_8c.html b/screen__calibrate_8c.html index deb8bb8..dcdf585 100644 --- a/screen__calibrate_8c.html +++ b/screen__calibrate_8c.html @@ -102,7 +102,9 @@ Include dependency graph for screen_calibrate.c:
- + +

Go to the source code of this file.

+
@@ -144,6 +146,13 @@ Variables

Functions

static void enter (void *screen)
+

Definition at line 23 of file screen_calibrate.c.

+
24 {
+ +
26 }
+
void tft_clear(uint16_t color)
Definition: tft.c:45
+
#define BLACK
Definition: tft.h:54
+

Here is the call graph for this function:
@@ -177,6 +186,11 @@ Here is the call graph for this function:
+

Definition at line 28 of file screen_calibrate.c.

+
29 {
+
30 
+
31 }
+
@@ -201,6 +215,100 @@ Here is the call graph for this function:
+

Definition at line 33 of file screen_calibrate.c.

+
34 {
+
35  int x1, y1, x2, y2, dx, dy;
+
36 
+
37 
+
38  tft_print_line(50, 50, WHITE, BLACK, 1, "Calibration:");
+
39  tft_print_line(50, 120, WHITE, BLACK, 0, "Hit the markers exactly!");
+
40  //-----------------First Point--------------------
+
41  tft_draw_line(CCENTER, CBEGIN, CCENTER, CEND, WHITE); //Draw Cross
+
42  tft_draw_line(CBEGIN, CCENTER, CEND, CCENTER, WHITE); //Draw Cross
+
43  calibration = 1; //TouchX + TouchY Values will not be converted to Pixels
+
44 
+
45  while (calibration); //Wait on PenUp
+
46 
+ +
48  x1 = p1.x;
+
49  y1 = p1.y;
+
50  tft_fill_rectangle(CBEGIN, CBEGIN, CEND, CEND, BLACK); //Clear Cross
+
51 
+
52  //-----------------Second Point-------------------
+ + +
55  calibration = 1;
+
56 
+
57  while (calibration);
+
58 
+ +
60  x2 = p2.x;
+
61  y2 = p2.y;
+ +
63 
+
64  //-----------------Third Point--------------------
+ + +
67  calibration = 1;
+
68 
+
69  while (calibration);
+
70 
+ +
72  x1 += p3.x; //Add(!) values. We'll build the average later
+
73  y2 += p3.y;
+ +
75 
+
76  //------------------4. Point---------------------
+ + +
79  calibration = 1;
+
80 
+
81  while (calibration);
+
82 
+ +
84  x2 += p4.x;
+
85  y1 += p4.y;
+ +
87  //-------------------Calculation---------------------
+
88  x1++; //Add 1 and divide by 2 later = +0.5 (for correct rounding)
+
89  y1++;
+
90  x2++;
+
91  y2++;
+
92  x1 >>= 1; //Divide by 2
+
93  y1 >>= 1;
+
94  x2 >>= 1;
+
95  y2 >>= 1;
+
96  dx = (x2 - x1); //Build the Difference
+
97  dy = (y2 - y1);
+
98 
+
99  touch_set_calibration_values(x1, dx, y1, dy);
+
100  tft_print_line(50, 120, WHITE, BLACK, 0, "Calibration Done. Press anywhere");
+
101 
+
102  calibration = 1;
+
103 
+
104  while (calibration);
+
105 
+
106  gui_screen_back();
+
107 
+
108 }
+
#define CCENTER
+
void tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:50
+
uint16_t y
The Y-Coordinate of the point.
Definition: touch.h:88
+
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
+
uint16_t x
The X-Coordinate of the point.
Definition: touch.h:87
+
#define DHEIGHT
+
#define CBEGIN
+
#define WHITE
Definition: tft.h:53
+
POINT_STRUCT touch_get_last_point()
Definition: touch.c:211
+
void tft_fill_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:67
+ +
#define DWIDTH
+
#define CEND
+
bool gui_screen_back()
Definition: screen.c:85
+
void touch_set_calibration_values(int xs, int dx, int ys, int dy)
Definition: touch.c:51
+
#define BLACK
Definition: tft.h:54
+
volatile bool calibration
Definition: touch.c:40
+

Here is the call graph for this function:
@@ -223,6 +331,8 @@ Here is the call graph for this function:
+

Definition at line 40 of file touch.c.

+
@@ -247,16 +357,18 @@ Here is the call graph for this function:
leave,
update
}
-
static void enter(void *screen)
Definition: screen_calibrate.c:9
-
static void update(void *screen)
Definition: screen_calibrate.c:17
-
static void leave(void *screen)
Definition: screen_calibrate.c:13
+
static void enter(void *screen)
+
static void update(void *screen)
+
static void leave(void *screen)
+

Definition at line 111 of file screen_calibrate.c.

+ diff --git a/screen__calibrate_8c_source.html b/screen__calibrate_8c_source.html new file mode 100644 index 0000000..165860d --- /dev/null +++ b/screen__calibrate_8c_source.html @@ -0,0 +1,248 @@ + + + + + + +discoverpixy: common/touch/screen_calibrate.c Source File + + + + + + + + + + +
+
+ + + + + + +
+
discoverpixy +
+
+
+ + + + + + +
+
+ + +
+ +
+ + +
+
+
+
screen_calibrate.c
+
+
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/touch/screen_calibrate.c
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-06-01 timolang@gmail.com 06227da Added calibrate screen (WIP). fixed bug in emulator drawing.
+
11 * 2015-06-01 timolang@gmail.com eb573bc Finalized calibration. Fixed a bug in screen module.
+
12 *
+
13 **************************************************************************************************************************************/
+
14 
+
15 #include "screen_calibrate.h"
+
16 #include "tft.h"
+
17 #include "touch.h"
+
18 
+
19 
+
20 extern volatile bool calibration; //from touch.c
+
21 
+
22 
+
23 static void enter(void* screen)
+
24 {
+ +
26 }
+
27 
+
28 static void leave(void* screen)
+
29 {
+
30 
+
31 }
+
32 
+
33 static void update(void* screen)
+
34 {
+
35  int x1, y1, x2, y2, dx, dy;
+
36 
+
37 
+
38  tft_print_line(50, 50, WHITE, BLACK, 1, "Calibration:");
+
39  tft_print_line(50, 120, WHITE, BLACK, 0, "Hit the markers exactly!");
+
40  //-----------------First Point--------------------
+
41  tft_draw_line(CCENTER, CBEGIN, CCENTER, CEND, WHITE); //Draw Cross
+
42  tft_draw_line(CBEGIN, CCENTER, CEND, CCENTER, WHITE); //Draw Cross
+
43  calibration = 1; //TouchX + TouchY Values will not be converted to Pixels
+
44 
+
45  while (calibration); //Wait on PenUp
+
46 
+ +
48  x1 = p1.x;
+
49  y1 = p1.y;
+
50  tft_fill_rectangle(CBEGIN, CBEGIN, CEND, CEND, BLACK); //Clear Cross
+
51 
+
52  //-----------------Second Point-------------------
+ + +
55  calibration = 1;
+
56 
+
57  while (calibration);
+
58 
+ +
60  x2 = p2.x;
+
61  y2 = p2.y;
+ +
63 
+
64  //-----------------Third Point--------------------
+ + +
67  calibration = 1;
+
68 
+
69  while (calibration);
+
70 
+ +
72  x1 += p3.x; //Add(!) values. We'll build the average later
+
73  y2 += p3.y;
+ +
75 
+
76  //------------------4. Point---------------------
+ + +
79  calibration = 1;
+
80 
+
81  while (calibration);
+
82 
+ +
84  x2 += p4.x;
+
85  y1 += p4.y;
+ +
87  //-------------------Calculation---------------------
+
88  x1++; //Add 1 and divide by 2 later = +0.5 (for correct rounding)
+
89  y1++;
+
90  x2++;
+
91  y2++;
+
92  x1 >>= 1; //Divide by 2
+
93  y1 >>= 1;
+
94  x2 >>= 1;
+
95  y2 >>= 1;
+
96  dx = (x2 - x1); //Build the Difference
+
97  dy = (y2 - y1);
+
98 
+
99  touch_set_calibration_values(x1, dx, y1, dy);
+
100  tft_print_line(50, 120, WHITE, BLACK, 0, "Calibration Done. Press anywhere");
+
101 
+
102  calibration = 1;
+
103 
+
104  while (calibration);
+
105 
+
106  gui_screen_back();
+
107 
+
108 }
+
109 
+
110 
+ +
112  enter,
+
113  leave,
+
114  update
+
115 };
+
116 
+
117 
+ +
119 {
+
120  return &screen;
+
121 }
+
#define CCENTER
+
void tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:50
+
uint16_t y
The Y-Coordinate of the point.
Definition: touch.h:88
+
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
+
uint16_t x
The X-Coordinate of the point.
Definition: touch.h:87
+
SCREEN_STRUCT * get_screen_calibrate()
+
#define DHEIGHT
+
static void enter(void *screen)
+ + +
void tft_clear(uint16_t color)
Definition: tft.c:45
+
#define CBEGIN
+ +
#define WHITE
Definition: tft.h:53
+
static void update(void *screen)
+
POINT_STRUCT touch_get_last_point()
Definition: touch.c:211
+
void tft_fill_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:67
+
static void leave(void *screen)
+
static SCREEN_STRUCT screen
+ +
#define DWIDTH
+
#define CEND
+ +
bool gui_screen_back()
Definition: screen.c:85
+
void touch_set_calibration_values(int xs, int dx, int ys, int dy)
Definition: touch.c:51
+
#define BLACK
Definition: tft.h:54
+
volatile bool calibration
Definition: touch.c:40
+
+ + + + diff --git a/screen__calibrate_8h.html b/screen__calibrate_8h.html index 2a81cef..c057830 100644 --- a/screen__calibrate_8h.html +++ b/screen__calibrate_8h.html @@ -141,6 +141,8 @@ Functions
+

Definition at line 44 of file screen_calibrate.h.

+
@@ -153,6 +155,8 @@ Functions
+

Definition at line 42 of file screen_calibrate.h.

+
@@ -165,6 +169,8 @@ Functions
+

Definition at line 45 of file screen_calibrate.h.

+
@@ -177,6 +183,8 @@ Functions
+

Definition at line 43 of file screen_calibrate.h.

+
@@ -189,6 +197,8 @@ Functions
+

Definition at line 47 of file screen_calibrate.h.

+
@@ -201,12 +211,14 @@ Functions
+

Definition at line 46 of file screen_calibrate.h.

+
diff --git a/screen__calibrate_8h_source.html b/screen__calibrate_8h_source.html index 5bf9936..fa18817 100644 --- a/screen__calibrate_8h_source.html +++ b/screen__calibrate_8h_source.html @@ -89,30 +89,44 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
screen_calibrate.h
-Go to the documentation of this file.
1 #include "screen.h"
-
2 
-
7 
-
8 
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/touch/screen_calibrate.h
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-06-01 timolang@gmail.com 06227da Added calibrate screen (WIP). fixed bug in emulator drawing.
+
11 * 2015-06-01 timolang@gmail.com eb573bc Finalized calibration. Fixed a bug in screen module.
+
12 *
+
13 **************************************************************************************************************************************/
14 
-
15 
- +
15 #include "screen.h"
+
16 
+
21 
22 
-
25 
-
26 
-
27 //TODO: Move this define to a common accessible, but private header file (they are used by screen_calibrate.c and touch.c)
-
28 #define CCENTER 20 //Pixel Distance from Sides for Calibration Cross
-
29 #define CLENGTH 10 //Length of the Calibration Cross Lines
-
30 #define CBEGIN (CCENTER-CLENGTH/2)
-
31 #define CEND (CCENTER + CLENGTH/2)
-
32 #define DWIDTH 320 //TODO: move define to tft module or make a function out of it
-
33 #define DHEIGHT 240 //TODO: move define to tft module or make a function out of it
-
SCREEN_STRUCT * get_screen_calibrate()
Definition: screen_calibrate.c:91
+
28 
+
29 
+ +
36 
+
39 
+
40 
+
41 //TODO: Move this define to a common accessible, but private header file (they are used by screen_calibrate.c and touch.c)
+
42 #define CCENTER 20 //Pixel Distance from Sides for Calibration Cross
+
43 #define CLENGTH 10 //Length of the Calibration Cross Lines
+
44 #define CBEGIN (CCENTER-CLENGTH/2)
+
45 #define CEND (CCENTER + CLENGTH/2)
+
46 #define DWIDTH 320 //TODO: move define to tft module or make a function out of it
+
47 #define DHEIGHT 240 //TODO: move define to tft module or make a function out of it
+
SCREEN_STRUCT * get_screen_calibrate()
-
Definition: screen.h:34
+
diff --git a/screen__filetest_8c.html b/screen__filetest_8c.html index 0f9ab94..5d26a79 100644 --- a/screen__filetest_8c.html +++ b/screen__filetest_8c.html @@ -104,7 +104,9 @@ Include dependency graph for screen_filetest.c:
- + +

Go to the source code of this file.

+
@@ -150,6 +152,12 @@ Variables

Functions

static void b_back_cb (void *button)
+

Definition at line 27 of file screen_filetest.c.

+
28 {
+ +
30 }
+
bool gui_screen_back()
Definition: screen.c:85
+

Here is the call graph for this function:
@@ -192,6 +200,151 @@ Here is the caller graph for this function:
+

Definition at line 35 of file screen_filetest.c.

+
36 {
+
37  tft_clear(HEX(0xBABECD));
+
38 
+
39  //Back button
+
40  b_back.base.x1 = 10; //Start X of Button
+
41  b_back.base.y1 = 200; //Start Y of Button
+
42  b_back.base.x2 = AUTO; //b_back.base.x1+160; //Auto Calculate X2 with String Width
+
43  b_back.base.y2 = AUTO; //Auto Calculate Y2 with String Height
+
44  b_back.txtcolor = WHITE; //Set foreground color
+
45  b_back.bgcolor = HEX(0xAE1010); //Set background color (Don't take 255 or 0 on at least one channel, to make shadows possible)
+
46  b_back.font = 0; //Select Font
+
47  b_back.text = "Back"; //Set Text (For formatted strings take sprintf)
+
48  b_back.callback = b_back_cb; //Call b_back_cb as Callback
+
49  gui_button_add(&b_back); //Register Button (and run the callback from now on)
+
50 
+
51  tft_draw_line(10, 30, 310, 30, BLACK);
+
52  tft_print_line(10, 18, BLUE, TRANSPARENT, 0, "Name D H RO Date Time Size");
+
53 
+
54  int y = 33;
+
55 
+ +
57 
+
58  if (dir == NULL) {
+
59  return;
+
60  }
+
61 
+
62  for (int i = 0; i < dir->num_files; i++) {
+
63  FILE_STRUCT* file = &(dir->files[i]);
+
64  tft_print_formatted(10, y,
+
65  (file->fattrib & F_DIR) ? GREEN : RED,
+
66  TRANSPARENT, 0, "%-13s%c %c %s %02u%02u%02u %02u:%02u:%02u %u",
+
67  file->fname,
+
68  (file->fattrib & F_DIR) ? 'D' : ' ',
+
69  (file->fattrib & F_HID) ? 'H' : ' ',
+
70  (file->fattrib & F_RDO) ? "R " : "RW",
+
71  file->fdate.day,
+
72  file->fdate.month,
+
73  (file->fdate.year + 1980) % 100,
+
74  file->ftime.hour,
+
75  file->ftime.min,
+
76  file->ftime.sec * 2,
+
77  file->fsize);
+
78  y += 14;
+
79  }
+
80 
+ +
82 
+
83  y += 14;
+
84 
+
85  FILE_HANDLE* file = filesystem_file_open("test.txt");
+
86 
+
87  if (file == NULL) {
+
88  tft_print_line(10, y, BLUE, TRANSPARENT, 0, "Could not open test.txt");
+
89  } else {
+
90  char buf [30];
+
91  int size = (file->fsize > 30) ? 29 : file->fsize - 1;
+
92  FILE_STATUS st = filesystem_file_read(file, buf, size);
+
93 
+
94  if (st == F_OK) {
+
95  buf[file->fpos] = '\0';
+
96  tft_print_formatted(10, y, BLUE, TRANSPARENT, 0, "test.txt contains \"%s\"", buf);
+
97  long num = strtol(&(buf[file->fpos - 4]), NULL, 0);
+
98  num++;
+
99 
+
100  y += 14;
+
101 
+
102  if (filesystem_file_seek(file, file->fpos - 4) != F_OK) {
+
103  tft_print_formatted(10, y, BLUE, TRANSPARENT, 0, "Could not seek to %d", file->fpos - 4);
+
104  } else {
+
105  sprintf(buf, "%04d", num);
+
106 
+
107  if (filesystem_file_write(file, buf, 4) != F_OK) {
+
108  tft_print_formatted(10, y, BLUE, TRANSPARENT, 0, "Could not write new number %d", num);
+
109  } else {
+
110  tft_print_formatted(10, y, BLUE, TRANSPARENT, 0, "New number written %d", num);
+
111  }
+
112  }
+
113  } else {
+
114  tft_print_line(10, y, BLUE, TRANSPARENT, 0, "Could not read from test.txt");
+
115  }
+
116 
+
117  }
+
118 
+
119  filesystem_file_close(file);
+
120 
+
121  image_test();
+
122 }
+
const char * text
The label of the button.
Definition: button.h:61
+
static BUTTON_STRUCT b_back
+
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
+
FILE_STATUS filesystem_file_seek(FILE_HANDLE *handle, uint32_t offset)
Definition: filesystem.c:43
+
uint32_t fsize
The total file size in bytes.
Definition: filesystem.h:84
+
void tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:50
+
unsigned sec
second/2 (0..29)
Definition: filesystem.h:55
+
uint16_t y1
Top Left Y-Coordinate of Area.
Definition: touch.h:75
+
void tft_print_formatted(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, const char *format,...)
Definition: tft.c:111
+
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
+
FILE_DATE_STRUCT fdate
Last modified date.
Definition: filesystem.h:63
+
unsigned day
day (1..31)
Definition: filesystem.h:46
+
uint8_t fattrib
File/Directory Attributes.
Definition: filesystem.h:65
+ +
uint16_t x1
Top Left X-Coordinate of Area.
Definition: touch.h:74
+
#define TRANSPARENT
Definition: tft.h:66
+
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 HEX(h)
Definition: tft.h:60
+
uint16_t y2
Bottom Right Y-Coordinate of Area.
Definition: touch.h:77
+
FILE_HANDLE * filesystem_file_open(const char *filename)
Definition: filesystem.c:33
+
void filesystem_file_close(FILE_HANDLE *handle)
Definition: filesystem.c:38
+
char * fname
File/Directory name.
Definition: filesystem.h:66
+
void tft_clear(uint16_t color)
Definition: tft.c:45
+
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
+
unsigned year
year from 1980 (0..127)
Definition: filesystem.h:44
+
uint16_t num_files
Number of files/directories in this directory.
Definition: filesystem.h:74
+
unsigned month
month (1..12)
Definition: filesystem.h:45
+
#define RED
Definition: tft.h:50
+
FILE_STATUS filesystem_file_write(FILE_HANDLE *handle, uint8_t *buf, uint32_t size)
Definition: filesystem.c:53
+
static void b_back_cb(void *button)
+
#define WHITE
Definition: tft.h:53
+
unsigned min
minute (0..59
Definition: filesystem.h:54
+ +
uint32_t fpos
The current byte-position in the file.
Definition: filesystem.h:83
+
File is hidden.
Definition: filesystem.h:34
+
unsigned hour
hour (0..23)
Definition: filesystem.h:53
+
Everything ok.
Definition: filesystem.h:91
+
FILE_STRUCT * files
An array with num_files FILE_STRUCT entries.
Definition: filesystem.h:75
+ +
DIRECTORY_STRUCT * filesystem_dir_open(const char *path)
Definition: filesystem.c:23
+
#define BLUE
Definition: tft.h:52
+
It's a directory and not a file.
Definition: filesystem.h:36
+
File is readonly. You cannot write to it.
Definition: filesystem.h:33
+
BUTTON_CALLBACK callback
Callback which is executed when the button is pressed.
Definition: button.h:58
+
uint8_t font
The number of the font to use.
Definition: button.h:60
+
FILE_STATUS
Definition: filesystem.h:90
+
#define GREEN
Definition: tft.h:51
+
void filesystem_dir_close(DIRECTORY_STRUCT *dir)
Definition: filesystem.c:28
+
static void image_test()
+
FILE_TIME_STRUCT ftime
Last modified time.
Definition: filesystem.h:64
+
FILE_STATUS filesystem_file_read(FILE_HANDLE *handle, uint8_t *buf, uint32_t size)
Definition: filesystem.c:48
+
#define BLACK
Definition: tft.h:54
+
uint32_t fsize
File size in bytes. 0 for directories.
Definition: filesystem.h:62
+

Here is the call graph for this function:
@@ -224,6 +377,23 @@ Here is the call graph for this function:
+

Definition at line 146 of file screen_filetest.c.

+
147 {
+
148 
+
149 
+
150  if (!tft_draw_bitmap_file_unscaled(250, 170, "cpu.bmp")) {
+
151  tft_print_line(10, 180, BLUE, TRANSPARENT, 0, "Could not open cpu.bmp");
+
152  }
+
153 
+
154  tft_draw_rectangle(250 - 1, 170 - 1, 250 - 1 + 64, 170 - 1 + 64, BLACK);
+
155 }
+
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
+
#define TRANSPARENT
Definition: tft.h:66
+
bool tft_draw_bitmap_file_unscaled(uint16_t x, uint16_t y, const char *filename)
Definition: tft.c:123
+
void tft_draw_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:61
+
#define BLUE
Definition: tft.h:52
+
#define BLACK
Definition: tft.h:54
+

Here is the call graph for this function:
@@ -266,6 +436,13 @@ Here is the caller graph for this function:
+

Definition at line 124 of file screen_filetest.c.

+
125 {
+ +
127 }
+
static BUTTON_STRUCT b_back
+
void gui_button_remove(BUTTON_STRUCT *button)
Definition: button.c:184
+

Here is the call graph for this function:
@@ -299,6 +476,10 @@ Here is the call graph for this function:
+

Definition at line 129 of file screen_filetest.c.

+
130 {
+
131 }
+

Variable Documentation

@@ -320,6 +501,8 @@ Here is the call graph for this function:
+

Definition at line 25 of file screen_filetest.c.

+
@@ -344,16 +527,18 @@ Here is the call graph for this function:
leave,
update
}
-
static void leave(void *screen)
Definition: screen_filetest.c:113
-
static void update(void *screen)
Definition: screen_filetest.c:117
-
static void enter(void *screen)
Definition: screen_filetest.c:17
+
static void leave(void *screen)
+
static void update(void *screen)
+
static void enter(void *screen)
+

Definition at line 134 of file screen_filetest.c.

+ diff --git a/screen__filetest_8c_source.html b/screen__filetest_8c_source.html new file mode 100644 index 0000000..8acc041 --- /dev/null +++ b/screen__filetest_8c_source.html @@ -0,0 +1,326 @@ + + + + + + +discoverpixy: common/app/screen_filetest.c Source File + + + + + + + + + + +
+
+ + + + + + +
+
discoverpixy +
+
+
+ + + + + + +
+
+ + +
+ +
+ + +
+
+
+
screen_filetest.c
+
+
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/app/screen_filetest.c
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-05-10 timolang@gmail.com e2bce8f Added filesystem module, tests and implementation for it in emulator.
+
11 * 2015-05-10 timolang@gmail.com 790f602 Added bitmap decoding/drawing example
+
12 * 2015-05-10 timolang@gmail.com 21edc56 Added doxyfile (doxygen) for the common folder. Started with doxygen comments for app and tft module.
+
13 * 2015-05-15 timolang@gmail.com 9a16865 Added doxgen comments to filesyste, checkbox, numupdown and screen module. And some minor changes to the other modules.
+
14 * 2015-05-15 timolang@gmail.com 85f1aee Changed filetest to use new bitmap draw method.
+
15 *
+
16 **************************************************************************************************************************************/
+
17 
+
18 #include "screen_filetest.h"
+
19 #include "button.h"
+
20 #include "tft.h"
+
21 #include "filesystem.h"
+
22 #include <stdlib.h>
+
23 
+
24 
+ +
26 
+
27 static void b_back_cb(void* button)
+
28 {
+ +
30 }
+
31 
+
32 
+
33 static void image_test();
+
34 
+
35 static void enter(void* screen)
+
36 {
+
37  tft_clear(HEX(0xBABECD));
+
38 
+
39  //Back button
+
40  b_back.base.x1 = 10; //Start X of Button
+
41  b_back.base.y1 = 200; //Start Y of Button
+
42  b_back.base.x2 = AUTO; //b_back.base.x1+160; //Auto Calculate X2 with String Width
+
43  b_back.base.y2 = AUTO; //Auto Calculate Y2 with String Height
+
44  b_back.txtcolor = WHITE; //Set foreground color
+
45  b_back.bgcolor = HEX(0xAE1010); //Set background color (Don't take 255 or 0 on at least one channel, to make shadows possible)
+
46  b_back.font = 0; //Select Font
+
47  b_back.text = "Back"; //Set Text (For formatted strings take sprintf)
+
48  b_back.callback = b_back_cb; //Call b_back_cb as Callback
+
49  gui_button_add(&b_back); //Register Button (and run the callback from now on)
+
50 
+
51  tft_draw_line(10, 30, 310, 30, BLACK);
+
52  tft_print_line(10, 18, BLUE, TRANSPARENT, 0, "Name D H RO Date Time Size");
+
53 
+
54  int y = 33;
+
55 
+ +
57 
+
58  if (dir == NULL) {
+
59  return;
+
60  }
+
61 
+
62  for (int i = 0; i < dir->num_files; i++) {
+
63  FILE_STRUCT* file = &(dir->files[i]);
+
64  tft_print_formatted(10, y,
+
65  (file->fattrib & F_DIR) ? GREEN : RED,
+
66  TRANSPARENT, 0, "%-13s%c %c %s %02u%02u%02u %02u:%02u:%02u %u",
+
67  file->fname,
+
68  (file->fattrib & F_DIR) ? 'D' : ' ',
+
69  (file->fattrib & F_HID) ? 'H' : ' ',
+
70  (file->fattrib & F_RDO) ? "R " : "RW",
+
71  file->fdate.day,
+
72  file->fdate.month,
+
73  (file->fdate.year + 1980) % 100,
+
74  file->ftime.hour,
+
75  file->ftime.min,
+
76  file->ftime.sec * 2,
+
77  file->fsize);
+
78  y += 14;
+
79  }
+
80 
+ +
82 
+
83  y += 14;
+
84 
+
85  FILE_HANDLE* file = filesystem_file_open("test.txt");
+
86 
+
87  if (file == NULL) {
+
88  tft_print_line(10, y, BLUE, TRANSPARENT, 0, "Could not open test.txt");
+
89  } else {
+
90  char buf [30];
+
91  int size = (file->fsize > 30) ? 29 : file->fsize - 1;
+
92  FILE_STATUS st = filesystem_file_read(file, buf, size);
+
93 
+
94  if (st == F_OK) {
+
95  buf[file->fpos] = '\0';
+
96  tft_print_formatted(10, y, BLUE, TRANSPARENT, 0, "test.txt contains \"%s\"", buf);
+
97  long num = strtol(&(buf[file->fpos - 4]), NULL, 0);
+
98  num++;
+
99 
+
100  y += 14;
+
101 
+
102  if (filesystem_file_seek(file, file->fpos - 4) != F_OK) {
+
103  tft_print_formatted(10, y, BLUE, TRANSPARENT, 0, "Could not seek to %d", file->fpos - 4);
+
104  } else {
+
105  sprintf(buf, "%04d", num);
+
106 
+
107  if (filesystem_file_write(file, buf, 4) != F_OK) {
+
108  tft_print_formatted(10, y, BLUE, TRANSPARENT, 0, "Could not write new number %d", num);
+
109  } else {
+
110  tft_print_formatted(10, y, BLUE, TRANSPARENT, 0, "New number written %d", num);
+
111  }
+
112  }
+
113  } else {
+
114  tft_print_line(10, y, BLUE, TRANSPARENT, 0, "Could not read from test.txt");
+
115  }
+
116 
+
117  }
+
118 
+
119  filesystem_file_close(file);
+
120 
+
121  image_test();
+
122 }
+
123 
+
124 static void leave(void* screen)
+
125 {
+
126  gui_button_remove(&b_back);
+
127 }
+
128 
+
129 static void update(void* screen)
+
130 {
+
131 }
+
132 
+
133 
+ +
135  enter,
+
136  leave,
+
137  update
+
138 };
+
139 
+
140 
+ +
142 {
+
143  return &screen;
+
144 }
+
145 
+
146 static void image_test()
+
147 {
+
148 
+
149 
+
150  if (!tft_draw_bitmap_file_unscaled(250, 170, "cpu.bmp")) {
+
151  tft_print_line(10, 180, BLUE, TRANSPARENT, 0, "Could not open cpu.bmp");
+
152  }
+
153 
+
154  tft_draw_rectangle(250 - 1, 170 - 1, 250 - 1 + 64, 170 - 1 + 64, BLACK);
+
155 }
+
const char * text
The label of the button.
Definition: button.h:61
+
static BUTTON_STRUCT b_back
+
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
+
FILE_STATUS filesystem_file_seek(FILE_HANDLE *handle, uint32_t offset)
Definition: filesystem.c:43
+
uint32_t fsize
The total file size in bytes.
Definition: filesystem.h:84
+
void tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:50
+
unsigned sec
second/2 (0..29)
Definition: filesystem.h:55
+
uint16_t y1
Top Left Y-Coordinate of Area.
Definition: touch.h:75
+
static void leave(void *screen)
+
void tft_print_formatted(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, const char *format,...)
Definition: tft.c:111
+ +
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
+
FILE_DATE_STRUCT fdate
Last modified date.
Definition: filesystem.h:63
+
unsigned day
day (1..31)
Definition: filesystem.h:46
+
uint8_t fattrib
File/Directory Attributes.
Definition: filesystem.h:65
+ +
uint16_t x1
Top Left X-Coordinate of Area.
Definition: touch.h:74
+
#define TRANSPARENT
Definition: tft.h:66
+
uint16_t bgcolor
The 16-bit background color of the button.
Definition: button.h:57
+
static void update(void *screen)
+
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 HEX(h)
Definition: tft.h:60
+
uint16_t y2
Bottom Right Y-Coordinate of Area.
Definition: touch.h:77
+ +
FILE_HANDLE * filesystem_file_open(const char *filename)
Definition: filesystem.c:33
+
void filesystem_file_close(FILE_HANDLE *handle)
Definition: filesystem.c:38
+
SCREEN_STRUCT * get_screen_filetest()
+
bool tft_draw_bitmap_file_unscaled(uint16_t x, uint16_t y, const char *filename)
Definition: tft.c:123
+ +
char * fname
File/Directory name.
Definition: filesystem.h:66
+
void tft_clear(uint16_t color)
Definition: tft.c:45
+
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
+ +
void gui_button_remove(BUTTON_STRUCT *button)
Definition: button.c:184
+
unsigned year
year from 1980 (0..127)
Definition: filesystem.h:44
+
uint16_t num_files
Number of files/directories in this directory.
Definition: filesystem.h:74
+
unsigned month
month (1..12)
Definition: filesystem.h:45
+
#define RED
Definition: tft.h:50
+
FILE_STATUS filesystem_file_write(FILE_HANDLE *handle, uint8_t *buf, uint32_t size)
Definition: filesystem.c:53
+ +
static void b_back_cb(void *button)
+
#define WHITE
Definition: tft.h:53
+
unsigned min
minute (0..59
Definition: filesystem.h:54
+ +
uint32_t fpos
The current byte-position in the file.
Definition: filesystem.h:83
+
File is hidden.
Definition: filesystem.h:34
+ +
unsigned hour
hour (0..23)
Definition: filesystem.h:53
+
static SCREEN_STRUCT screen
+
Everything ok.
Definition: filesystem.h:91
+
FILE_STRUCT * files
An array with num_files FILE_STRUCT entries.
Definition: filesystem.h:75
+ +
void tft_draw_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:61
+
DIRECTORY_STRUCT * filesystem_dir_open(const char *path)
Definition: filesystem.c:23
+
#define BLUE
Definition: tft.h:52
+
It's a directory and not a file.
Definition: filesystem.h:36
+
File is readonly. You cannot write to it.
Definition: filesystem.h:33
+
BUTTON_CALLBACK callback
Callback which is executed when the button is pressed.
Definition: button.h:58
+
bool gui_screen_back()
Definition: screen.c:85
+
uint8_t font
The number of the font to use.
Definition: button.h:60
+
FILE_STATUS
Definition: filesystem.h:90
+
static void enter(void *screen)
+
#define GREEN
Definition: tft.h:51
+
void filesystem_dir_close(DIRECTORY_STRUCT *dir)
Definition: filesystem.c:28
+
static void image_test()
+
FILE_TIME_STRUCT ftime
Last modified time.
Definition: filesystem.h:64
+
FILE_STATUS filesystem_file_read(FILE_HANDLE *handle, uint8_t *buf, uint32_t size)
Definition: filesystem.c:48
+
#define BLACK
Definition: tft.h:54
+
uint32_t fsize
File size in bytes. 0 for directories.
Definition: filesystem.h:62
+
+ + + + diff --git a/screen__filetest_8h.html b/screen__filetest_8h.html index 0b5191b..dbed61e 100644 --- a/screen__filetest_8h.html +++ b/screen__filetest_8h.html @@ -117,7 +117,7 @@ Functions diff --git a/screen__filetest_8h_source.html b/screen__filetest_8h_source.html index f761a71..c0ea19e 100644 --- a/screen__filetest_8h_source.html +++ b/screen__filetest_8h_source.html @@ -89,20 +89,35 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
screen_filetest.h
-Go to the documentation of this file.
1 #include "screen.h"
-
2 
-
7 
-
13 
-
14 
- -
21 
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/app/screen_filetest.h
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-05-10 timolang@gmail.com e2bce8f Added filesystem module, tests and implementation for it in emulator.
+
11 * 2015-05-10 timolang@gmail.com 21edc56 Added doxyfile (doxygen) for the common folder. Started with doxygen comments for app and tft module.
+
12 * 2015-05-15 timolang@gmail.com 9a16865 Added doxgen comments to filesyste, checkbox, numupdown and screen module. And some minor changes to the other modules.
+
13 *
+
14 **************************************************************************************************************************************/
+
15 
+
16 #include "screen.h"
+
17 
+
22 
+
28 
+
29 
+ +
36 
-
SCREEN_STRUCT * get_screen_filetest()
Definition: screen_filetest.c:128
-
Definition: screen.h:34
+
SCREEN_STRUCT * get_screen_filetest()
+
diff --git a/screen__guitest_8c.html b/screen__guitest_8c.html index f714b61..5d39b06 100644 --- a/screen__guitest_8c.html +++ b/screen__guitest_8c.html @@ -104,7 +104,9 @@ Include dependency graph for screen_guitest.c:
- + +

Go to the source code of this file.

+
@@ -160,6 +162,12 @@ Variables

Functions

static void checkboxCB (void *checkbox, bool checked)
+

Definition at line 35 of file screen_guitest.c.

+
36 {
+ +
38 }
+
bool gui_screen_back()
Definition: screen.c:85
+

Here is the call graph for this function:
@@ -212,6 +220,11 @@ Here is the caller graph for this function:
+

Definition at line 30 of file screen_guitest.c.

+
31 {
+
32  printf("Checkbox %s\n", (checked ? "checked" : "unchecked"));
+
33 }
+

Here is the caller graph for this function:
@@ -245,6 +258,125 @@ Here is the caller graph for this function:
+

Definition at line 75 of file screen_guitest.c.

+
76 {
+
77  tft_clear(HEX(0xA6FD9A));
+
78 
+
79  //Back button
+
80  b_back.base.x1 = 10; //Start X of Button
+
81  b_back.base.y1 = 10; //Start Y of Button
+
82  b_back.base.x2 = AUTO; //b_back.base.x1+160; //Auto Calculate X2 with String Width
+
83  b_back.base.y2 = AUTO; //Auto Calculate Y2 with String Height
+
84  b_back.txtcolor = WHITE; //Set foreground color
+
85  b_back.bgcolor = HEX(0xAE1010); //Set background color (Don't take 255 or 0 on at least one channel, to make shadows possible)
+
86  b_back.font = 0; //Select Font
+
87  b_back.text = "Back"; //Set Text (For formatted strings take sprintf)
+
88  b_back.callback = b_back_cb; //Call b_back_cb as Callback
+
89  gui_button_add(&b_back); //Register Button (and run the callback from now on)
+
90 
+
91 
+
92  //tft test
+
93  tft_draw_pixel(0, 0, BLACK);
+
94  tft_draw_pixel(319, 239, BLACK);
+
95  tft_draw_pixel(10, 210, BLUE);
+
96  tft_draw_pixel(12, 210, BLUE);
+
97  tft_draw_rectangle(40, 100, 60, 235, BLUE);
+
98  tft_fill_rectangle(100, 215, 200, 225, GREEN);
+
99  tft_draw_line(10, 50, 310, 225, RGB(0xFF, 0, 0xFF));
+
100  tft_draw_circle(10, 10, 100, RED);
+
101  tft_print_line(30, 130, RED, BLUE, 0, "Hallo");
+
102 
+
103 
+
104 
+
105  //Area test
+ +
107  a_area.x1 = 130;
+
108  a_area.y1 = 30;
+
109  a_area.x2 = 200;
+
110  a_area.y2 = 60;
+ + +
113 
+
114 
+
115 
+
116  //Checkbox test
+
117  c_cbox.base.x1 = 220;
+
118  c_cbox.base.y1 = 45;
+
119  c_cbox.base.x2 = c_cbox.base.x1 + 16;
+
120  c_cbox.base.y2 = c_cbox.base.y1 + 16;
+
121  c_cbox.fgcolor = GREEN;
+
122  c_cbox.checked = true;
+ + +
125 
+
126 
+
127  //Num up down test
+
128  n_updown.x = 200;
+
129  n_updown.y = 120;
+
130  n_updown.fgcolor = RED;
+
131  n_updown.value = -3;
+
132  n_updown.max = 11;
+
133  n_updown.min = -5;
+ + +
136 
+
137 }
+
bool touch_register_area(TOUCH_AREA_STRUCT *area)
Definition: touch.c:181
+
const char * text
The label of the button.
Definition: button.h:61
+
Receive an event when the pen moves inside the region (pen is down)
Definition: touch.h:58
+
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
+
Receive an event when the pen goes down inside the region.
Definition: touch.h:54
+
Receive an event when the pen goes up inside the region.
Definition: touch.h:55
+
bool gui_checkbox_add(CHECKBOX_STRUCT *checkbox)
Definition: checkbox.c:70
+
void tft_draw_circle(uint16_t x, uint16_t y, uint16_t r, uint16_t color)
Definition: tft.c:77
+
void tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:50
+
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
+
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
+
#define RGB(r, g, b)
Definition: tft.h:48
+
uint16_t x1
Top Left X-Coordinate of Area.
Definition: touch.h:74
+
bool checked
A boolean which indicates whether or not the checkbox is currently checked.
Definition: checkbox.h:53
+
uint16_t bgcolor
The 16-bit background color of the button.
Definition: button.h:57
+
static void touchCB(void *touchArea, TOUCH_ACTION triggeredAction)
+
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
+
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
+
uint16_t y
The y-Coordinate of the Top-Left Starting Point.
Definition: numupdown.h:50
+
int16_t max
The maximum possible value (inclusive)
Definition: numupdown.h:54
+
void tft_draw_pixel(uint16_t x, uint16_t y, uint16_t color)
Definition: tft.c:56
+
TOUCH_CALLBACK callback
Callback which is executed when an event occurred in this Area.
Definition: touch.h:78
+
void tft_clear(uint16_t color)
Definition: tft.c:45
+
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
+
Receive an event when the pen enters the region (pen was down before)
Definition: touch.h:56
+
int16_t min
The minimum possible value (inclusive)
Definition: numupdown.h:53
+
#define RED
Definition: tft.h:50
+
#define WHITE
Definition: tft.h:53
+
void tft_fill_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:67
+
static TOUCH_AREA_STRUCT a_area
+
TOUCH_ACTION hookedActions
Actions to listen to.
Definition: touch.h:73
+
static void checkboxCB(void *checkbox, bool checked)
+
uint16_t fgcolor
The 16-bit color of the value-text.
Definition: numupdown.h:51
+
void tft_draw_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:61
+
#define BLUE
Definition: tft.h:52
+
static void n_updown_cb(void *numupdown, int16_t value)
+
TOUCH_AREA_STRUCT base
Basic geometry of the Checkbox. You only need to set the x1, y1, x2, y2 members of this struct...
Definition: checkbox.h:51
+
static NUMUPDOWN_STRUCT n_updown
+
int16_t value
The current/default value.
Definition: numupdown.h:52
+
uint16_t fgcolor
The 16-bit color of the tickmark.
Definition: checkbox.h:52
+
static BUTTON_STRUCT b_back
+
BUTTON_CALLBACK callback
Callback which is executed when the button is pressed.
Definition: button.h:58
+
CHECKBOX_CALLBACK callback
Callback which is executed when the checkbox changes state.
Definition: checkbox.h:54
+
uint8_t font
The number of the font to use.
Definition: button.h:60
+
#define GREEN
Definition: tft.h:51
+
static void b_back_cb(void *button)
+
static CHECKBOX_STRUCT c_cbox
+
#define BLACK
Definition: tft.h:54
+
Receive an event when the pen leaves the region (pen was inside region before)
Definition: touch.h:57
+
bool gui_numupdown_add(NUMUPDOWN_STRUCT *numupdown)
Definition: numupdown.c:80
+

Here is the call graph for this function:
@@ -278,6 +410,22 @@ Here is the call graph for this function:
+

Definition at line 139 of file screen_guitest.c.

+
140 {
+ + + + +
145 }
+
void gui_checkbox_remove(CHECKBOX_STRUCT *checkbox)
Definition: checkbox.c:119
+
void touch_unregister_area(TOUCH_AREA_STRUCT *area)
Definition: touch.c:195
+
void gui_numupdown_remove(NUMUPDOWN_STRUCT *numupdown)
Definition: numupdown.c:136
+
void gui_button_remove(BUTTON_STRUCT *button)
Definition: button.c:184
+
static TOUCH_AREA_STRUCT a_area
+
static NUMUPDOWN_STRUCT n_updown
+
static BUTTON_STRUCT b_back
+
static CHECKBOX_STRUCT c_cbox
+

Here is the call graph for this function:
@@ -321,6 +469,11 @@ Here is the call graph for this function:
+

Definition at line 40 of file screen_guitest.c.

+
41 {
+
42  printf("New NumUpDown Value %d\n", value);
+
43 }
+

Here is the caller graph for this function:
@@ -364,6 +517,41 @@ Here is the caller graph for this function:
+

Definition at line 45 of file screen_guitest.c.

+
46 {
+
47 
+
48  switch (triggeredAction) {
+
49  case PEN_DOWN:
+
50  printf("action PEN_DOWN\n");
+
51  break;
+
52 
+
53  case PEN_UP:
+
54  printf("action PEN_UP\n");
+
55  break;
+
56 
+
57  case PEN_MOVE:
+
58  printf("action PEN_MOVE\n");
+
59  break;
+
60 
+
61  case PEN_ENTER:
+
62  printf("action PEN_ENTER\n");
+
63  break;
+
64 
+
65  case PEN_LEAVE:
+
66  printf("action PEN_LEAVE\n");
+
67  break;
+
68 
+
69  default:
+
70  printf("action %s\n", triggeredAction);
+
71  break;
+
72  }
+
73 }
+
Receive an event when the pen moves inside the region (pen is down)
Definition: touch.h:58
+
Receive an event when the pen goes down inside the region.
Definition: touch.h:54
+
Receive an event when the pen goes up inside the region.
Definition: touch.h:55
+
Receive an event when the pen enters the region (pen was down before)
Definition: touch.h:56
+
Receive an event when the pen leaves the region (pen was inside region before)
Definition: touch.h:57
+

Here is the caller graph for this function:
@@ -397,6 +585,12 @@ Here is the caller graph for this function:
+

Definition at line 147 of file screen_guitest.c.

+
148 {
+
149  //gui_button_redraw(&b_back); //only needed if button is overdrawn by others
+
150  //.... for the other elements as well
+
151 }
+

Variable Documentation

@@ -418,6 +612,8 @@ Here is the caller graph for this function:
+

Definition at line 26 of file screen_guitest.c.

+
@@ -438,6 +634,8 @@ Here is the caller graph for this function:
+

Definition at line 25 of file screen_guitest.c.

+
@@ -458,6 +656,8 @@ Here is the caller graph for this function:
+

Definition at line 27 of file screen_guitest.c.

+
@@ -478,6 +678,8 @@ Here is the caller graph for this function:
+

Definition at line 28 of file screen_guitest.c.

+
@@ -502,16 +704,18 @@ Here is the caller graph for this function:
leave,
update
}
-
static void update(void *screen)
Definition: screen_guitest.c:118
-
static void enter(void *screen)
Definition: screen_guitest.c:48
-
static void leave(void *screen)
Definition: screen_guitest.c:111
+
static void update(void *screen)
+
static void enter(void *screen)
+
static void leave(void *screen)
+

Definition at line 154 of file screen_guitest.c.

+ diff --git a/screen__guitest_8c_source.html b/screen__guitest_8c_source.html new file mode 100644 index 0000000..5caa43d --- /dev/null +++ b/screen__guitest_8c_source.html @@ -0,0 +1,340 @@ + + + + + + +discoverpixy: common/app/screen_guitest.c Source File + + + + + + + + + + +
+
+ + + + + + +
+
discoverpixy +
+
+
+ + + + + + +
+
+ + +
+ +
+ + +
+
+
+
screen_guitest.c
+
+
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/app/screen_guitest.c
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-04-27 timolang@gmail.com cf72baa Introduced a Screen (sub) module and divided app into multiple screens.
+
11 * 2015-04-30 timolang@gmail.com 76ea9d8 Added num up down support.
+
12 * 2015-05-09 timolang@gmail.com c652b6b Improved Emulator Gui
+
13 * 2015-05-29 aaron@duckpond.ch 7d2d1a1 Implemented basic sampling and averaging of touch coordinates using timer7
+
14 * 2015-06-01 timolang@gmail.com eb573bc Finalized calibration. Fixed a bug in screen module.
+
15 * 2015-06-02 timolang@gmail.com da34bce Fixed all printf related problems on discovery using workarounds and newlib nano-instead of newlib
+
16 *
+
17 **************************************************************************************************************************************/
+
18 
+
19 #include "screen_guitest.h"
+
20 #include "button.h"
+
21 #include "tft.h"
+
22 #include "checkbox.h"
+
23 #include "numupdown.h"
+
24 
+ + + + +
29 
+
30 static void checkboxCB(void* checkbox, bool checked)
+
31 {
+
32  printf("Checkbox %s\n", (checked ? "checked" : "unchecked"));
+
33 }
+
34 
+
35 static void b_back_cb(void* button)
+
36 {
+ +
38 }
+
39 
+
40 static void n_updown_cb(void* numupdown, int16_t value)
+
41 {
+
42  printf("New NumUpDown Value %d\n", value);
+
43 }
+
44 
+
45 static void touchCB(void* touchArea, TOUCH_ACTION triggeredAction)
+
46 {
+
47 
+
48  switch (triggeredAction) {
+
49  case PEN_DOWN:
+
50  printf("action PEN_DOWN\n");
+
51  break;
+
52 
+
53  case PEN_UP:
+
54  printf("action PEN_UP\n");
+
55  break;
+
56 
+
57  case PEN_MOVE:
+
58  printf("action PEN_MOVE\n");
+
59  break;
+
60 
+
61  case PEN_ENTER:
+
62  printf("action PEN_ENTER\n");
+
63  break;
+
64 
+
65  case PEN_LEAVE:
+
66  printf("action PEN_LEAVE\n");
+
67  break;
+
68 
+
69  default:
+
70  printf("action %s\n", triggeredAction);
+
71  break;
+
72  }
+
73 }
+
74 
+
75 static void enter(void* screen)
+
76 {
+
77  tft_clear(HEX(0xA6FD9A));
+
78 
+
79  //Back button
+
80  b_back.base.x1 = 10; //Start X of Button
+
81  b_back.base.y1 = 10; //Start Y of Button
+
82  b_back.base.x2 = AUTO; //b_back.base.x1+160; //Auto Calculate X2 with String Width
+
83  b_back.base.y2 = AUTO; //Auto Calculate Y2 with String Height
+
84  b_back.txtcolor = WHITE; //Set foreground color
+
85  b_back.bgcolor = HEX(0xAE1010); //Set background color (Don't take 255 or 0 on at least one channel, to make shadows possible)
+
86  b_back.font = 0; //Select Font
+
87  b_back.text = "Back"; //Set Text (For formatted strings take sprintf)
+
88  b_back.callback = b_back_cb; //Call b_back_cb as Callback
+
89  gui_button_add(&b_back); //Register Button (and run the callback from now on)
+
90 
+
91 
+
92  //tft test
+
93  tft_draw_pixel(0, 0, BLACK);
+
94  tft_draw_pixel(319, 239, BLACK);
+
95  tft_draw_pixel(10, 210, BLUE);
+
96  tft_draw_pixel(12, 210, BLUE);
+
97  tft_draw_rectangle(40, 100, 60, 235, BLUE);
+
98  tft_fill_rectangle(100, 215, 200, 225, GREEN);
+
99  tft_draw_line(10, 50, 310, 225, RGB(0xFF, 0, 0xFF));
+
100  tft_draw_circle(10, 10, 100, RED);
+
101  tft_print_line(30, 130, RED, BLUE, 0, "Hallo");
+
102 
+
103 
+
104 
+
105  //Area test
+ +
107  a_area.x1 = 130;
+
108  a_area.y1 = 30;
+
109  a_area.x2 = 200;
+
110  a_area.y2 = 60;
+
111  a_area.callback = touchCB;
+
112  touch_register_area(&a_area);
+
113 
+
114 
+
115 
+
116  //Checkbox test
+
117  c_cbox.base.x1 = 220;
+
118  c_cbox.base.y1 = 45;
+
119  c_cbox.base.x2 = c_cbox.base.x1 + 16;
+
120  c_cbox.base.y2 = c_cbox.base.y1 + 16;
+
121  c_cbox.fgcolor = GREEN;
+
122  c_cbox.checked = true;
+
123  c_cbox.callback = checkboxCB;
+
124  gui_checkbox_add(&c_cbox);
+
125 
+
126 
+
127  //Num up down test
+
128  n_updown.x = 200;
+
129  n_updown.y = 120;
+
130  n_updown.fgcolor = RED;
+
131  n_updown.value = -3;
+
132  n_updown.max = 11;
+
133  n_updown.min = -5;
+
134  n_updown.callback = n_updown_cb;
+
135  gui_numupdown_add(&n_updown);
+
136 
+
137 }
+
138 
+
139 static void leave(void* screen)
+
140 {
+
141  gui_button_remove(&b_back);
+
142  gui_checkbox_remove(&c_cbox);
+
143  gui_numupdown_remove(&n_updown);
+
144  touch_unregister_area(&a_area);
+
145 }
+
146 
+
147 static void update(void* screen)
+
148 {
+
149  //gui_button_redraw(&b_back); //only needed if button is overdrawn by others
+
150  //.... for the other elements as well
+
151 }
+
152 
+
153 
+ +
155  enter,
+
156  leave,
+
157  update
+
158 };
+
159 
+
160 
+ +
162 {
+
163  return &screen;
+
164 }
+
TOUCH_ACTION
Definition: touch.h:52
+
bool touch_register_area(TOUCH_AREA_STRUCT *area)
Definition: touch.c:181
+
const char * text
The label of the button.
Definition: button.h:61
+
Receive an event when the pen moves inside the region (pen is down)
Definition: touch.h:58
+
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
+
Receive an event when the pen goes down inside the region.
Definition: touch.h:54
+
Receive an event when the pen goes up inside the region.
Definition: touch.h:55
+
bool gui_checkbox_add(CHECKBOX_STRUCT *checkbox)
Definition: checkbox.c:70
+
void tft_draw_circle(uint16_t x, uint16_t y, uint16_t r, uint16_t color)
Definition: tft.c:77
+
void tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:50
+
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 void update(void *screen)
+ +
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
+
#define RGB(r, g, b)
Definition: tft.h:48
+
void gui_checkbox_remove(CHECKBOX_STRUCT *checkbox)
Definition: checkbox.c:119
+
uint16_t x1
Top Left X-Coordinate of Area.
Definition: touch.h:74
+
bool checked
A boolean which indicates whether or not the checkbox is currently checked.
Definition: checkbox.h:53
+
uint16_t bgcolor
The 16-bit background color of the button.
Definition: button.h:57
+
static void touchCB(void *touchArea, TOUCH_ACTION triggeredAction)
+
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
+ +
NUMUPDOWN_CALLBACK callback
Callback which is executed when the value changes.
Definition: numupdown.h:55
+
void touch_unregister_area(TOUCH_AREA_STRUCT *area)
Definition: touch.c:195
+ +
#define HEX(h)
Definition: tft.h:60
+ + +
uint16_t y2
Bottom Right Y-Coordinate of Area.
Definition: touch.h:77
+ +
uint16_t y
The y-Coordinate of the Top-Left Starting Point.
Definition: numupdown.h:50
+
static void enter(void *screen)
+
int16_t max
The maximum possible value (inclusive)
Definition: numupdown.h:54
+
void tft_draw_pixel(uint16_t x, uint16_t y, uint16_t color)
Definition: tft.c:56
+ + +
TOUCH_CALLBACK callback
Callback which is executed when an event occurred in this Area.
Definition: touch.h:78
+ +
void tft_clear(uint16_t color)
Definition: tft.c:45
+
void gui_numupdown_remove(NUMUPDOWN_STRUCT *numupdown)
Definition: numupdown.c:136
+
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
+
void gui_button_remove(BUTTON_STRUCT *button)
Definition: button.c:184
+
Receive an event when the pen enters the region (pen was down before)
Definition: touch.h:56
+
int16_t min
The minimum possible value (inclusive)
Definition: numupdown.h:53
+
#define RED
Definition: tft.h:50
+
static void leave(void *screen)
+ +
#define WHITE
Definition: tft.h:53
+
void tft_fill_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:67
+
static TOUCH_AREA_STRUCT a_area
+
TOUCH_ACTION hookedActions
Actions to listen to.
Definition: touch.h:73
+
static void checkboxCB(void *checkbox, bool checked)
+
uint16_t fgcolor
The 16-bit color of the value-text.
Definition: numupdown.h:51
+
void tft_draw_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:61
+
#define BLUE
Definition: tft.h:52
+
static void n_updown_cb(void *numupdown, int16_t value)
+
SCREEN_STRUCT * get_screen_guitest()
+
static SCREEN_STRUCT screen
+
TOUCH_AREA_STRUCT base
Basic geometry of the Checkbox. You only need to set the x1, y1, x2, y2 members of this struct...
Definition: checkbox.h:51
+
static NUMUPDOWN_STRUCT n_updown
+
int16_t value
The current/default value.
Definition: numupdown.h:52
+
uint16_t fgcolor
The 16-bit color of the tickmark.
Definition: checkbox.h:52
+
static BUTTON_STRUCT b_back
+
BUTTON_CALLBACK callback
Callback which is executed when the button is pressed.
Definition: button.h:58
+
bool gui_screen_back()
Definition: screen.c:85
+
CHECKBOX_CALLBACK callback
Callback which is executed when the checkbox changes state.
Definition: checkbox.h:54
+
uint8_t font
The number of the font to use.
Definition: button.h:60
+
#define GREEN
Definition: tft.h:51
+
static void b_back_cb(void *button)
+
static CHECKBOX_STRUCT c_cbox
+
#define BLACK
Definition: tft.h:54
+
Receive an event when the pen leaves the region (pen was inside region before)
Definition: touch.h:57
+
bool gui_numupdown_add(NUMUPDOWN_STRUCT *numupdown)
Definition: numupdown.c:80
+
+ + + + diff --git a/screen__guitest_8h.html b/screen__guitest_8h.html index 3492064..b87c2be 100644 --- a/screen__guitest_8h.html +++ b/screen__guitest_8h.html @@ -117,7 +117,7 @@ Functions diff --git a/screen__guitest_8h_source.html b/screen__guitest_8h_source.html index ac1097f..50e46d1 100644 --- a/screen__guitest_8h_source.html +++ b/screen__guitest_8h_source.html @@ -89,21 +89,36 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
screen_guitest.h
-Go to the documentation of this file.
1 #include "screen.h"
-
2 
-
3 
-
8 
-
14 
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/app/screen_guitest.h
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-04-27 timolang@gmail.com cf72baa Introduced a Screen (sub) module and divided app into multiple screens.
+
11 * 2015-05-10 timolang@gmail.com 21edc56 Added doxyfile (doxygen) for the common folder. Started with doxygen comments for app and tft module.
+
12 * 2015-05-15 timolang@gmail.com 9a16865 Added doxgen comments to filesyste, checkbox, numupdown and screen module. And some minor changes to the other modules.
+
13 *
+
14 **************************************************************************************************************************************/
15 
- -
22 
+
16 #include "screen.h"
+
17 
+
18 
+
23 
+
29 
+
30 
+ +
37 
-
Definition: screen.h:34
-
SCREEN_STRUCT * get_screen_guitest()
Definition: screen_guitest.c:131
+ +
SCREEN_STRUCT * get_screen_guitest()
diff --git a/screen__main_8c.html b/screen__main_8c.html index 2cadd53..d5f104b 100644 --- a/screen__main_8c.html +++ b/screen__main_8c.html @@ -109,7 +109,9 @@ Include dependency graph for screen_main.c:
- + +

Go to the source code of this file.

+
@@ -247,6 +249,13 @@ Variables

Macros

#define X_TAB   97
+

Definition at line 60 of file screen_main.c.

+
61 {
+ +
63 }
+
SCREEN_STRUCT * get_screen_filetest()
+
bool gui_screen_navigate(SCREEN_STRUCT *screen)
Definition: screen.c:74
+

Here is the call graph for this function:
@@ -289,6 +298,13 @@ Here is the caller graph for this function:
+

Definition at line 55 of file screen_main.c.

+
56 {
+ +
58 }
+
bool gui_screen_navigate(SCREEN_STRUCT *screen)
Definition: screen.c:74
+
SCREEN_STRUCT * get_screen_guitest()
+

Here is the call graph for this function:
@@ -331,6 +347,16 @@ Here is the caller graph for this function:
+

Definition at line 38 of file screen_main.c.

+
39 {
+ + +
42 }
+
void tracking_set_mode(enum Tracking_Implementation impl)
+
bool gui_screen_navigate(SCREEN_STRUCT *screen)
Definition: screen.c:74
+
SCREEN_STRUCT * get_screen_tracking()
+
Our own tracking PID implementation.
+

Here is the call graph for this function:
@@ -373,6 +399,13 @@ Here is the caller graph for this function:
+

Definition at line 50 of file screen_main.c.

+
51 {
+ +
53 }
+
bool gui_screen_navigate(SCREEN_STRUCT *screen)
Definition: screen.c:74
+
SCREEN_STRUCT * get_screen_photomode()
+

Here is the call graph for this function:
@@ -415,6 +448,13 @@ Here is the caller graph for this function:
+

Definition at line 65 of file screen_main.c.

+
66 {
+ +
68 }
+
SCREEN_STRUCT * get_screen_pixytest()
+
bool gui_screen_navigate(SCREEN_STRUCT *screen)
Definition: screen.c:74
+

Here is the call graph for this function:
@@ -457,6 +497,16 @@ Here is the caller graph for this function:
+

Definition at line 44 of file screen_main.c.

+
45 {
+ + +
48 }
+
void tracking_set_mode(enum Tracking_Implementation impl)
+
Pixy's internal tracking implementation.
+
bool gui_screen_navigate(SCREEN_STRUCT *screen)
Definition: screen.c:74
+
SCREEN_STRUCT * get_screen_tracking()
+

Here is the call graph for this function:
@@ -499,6 +549,146 @@ Here is the caller graph for this function:
+

Definition at line 71 of file screen_main.c.

+
72 {
+ +
74 
+
75  //Heading
+
76  tft_print_line(10, 10, BLUE, TRANSPARENT, 1, "Discoverpixy");
+
77  tft_draw_line(0, 40, 319, 40, BLACK);
+
78 
+
79 #define X_TAB 97
+
80 #define BUTTON_SPACING 7
+
81 
+
82  //First line of buttons
+
83 #define Y_FIRST 60
+
84  tft_print_line(10, Y_FIRST, BLACK, TRANSPARENT, 0, "Tracking:");
+
85 
+
86  b_our_tracking.base.x1 = X_TAB; //Start X of Button
+
87  b_our_tracking.base.y1 = Y_FIRST - 3; //Start Y of Button
+
88  b_our_tracking.base.x2 = AUTO; //Auto Calculate X2 with String Width
+
89  b_our_tracking.base.y2 = AUTO; //Auto Calculate Y2 with String Height
+
90  b_our_tracking.txtcolor = WHITE; //Set foreground color
+
91  b_our_tracking.bgcolor = HEX(0xE30535); //Set background color (Don't take 255 or 0 on at least one channel, to make shadows possible)
+
92  b_our_tracking.font = 0; //Select Font
+
93  b_our_tracking.text = "Our Tracking"; //Set Text (For formatted strings take sprintf)
+
94  b_our_tracking.callback = b_our_tracking_cb; //Call b_our_tracking when the button get's pressed
+
95  gui_button_add(&b_our_tracking); //Register Button (and run the callback from now on)
+
96 
+
97 
+ + + + + +
103  b_ref_tracking.bgcolor = HEX(0xFF2151);
+
104  b_ref_tracking.font = 0;
+
105  b_ref_tracking.text = "Ref Tracking";
+ + +
108 
+
109  //Second line of buttons
+
110 #define Y_SECOND Y_FIRST+25
+
111  tft_print_line(10, Y_SECOND, BLACK, TRANSPARENT, 0, "Photo mode:");
+
112 
+ + + + + +
118  b_photo_mode.bgcolor = HEX(0x21B1FF);
+
119  b_photo_mode.font = 0;
+
120  b_photo_mode.text = "Photo Mode";
+ + +
123 
+
124 
+
125  //Third line of buttons
+
126 #define Y_THIRD Y_SECOND+25
+
127  tft_print_line(10, Y_THIRD, BLACK, TRANSPARENT, 0, "Tests:");
+
128 
+ +
130  b_guitest.base.y1 = Y_THIRD - 3;
+
131  b_guitest.base.x2 = AUTO;
+
132  b_guitest.base.y2 = AUTO;
+ +
134  b_guitest.bgcolor = HEX(0x00FA21);
+
135  b_guitest.font = 0;
+
136  b_guitest.text = "Gui & Tft";
+ + +
139 
+
140 
+ +
142  b_pixytest.base.y1 = Y_THIRD - 3;
+ + + +
146  b_pixytest.bgcolor = HEX(0x00FA96);
+
147  b_pixytest.font = 0;
+
148  b_pixytest.text = "Pixy";
+ + +
151 
+
152 
+ +
154  b_filetest.base.y1 = Y_THIRD - 3;
+ + + +
158  b_filetest.bgcolor = HEX(0x00FAC4);
+
159  b_filetest.font = 0;
+
160  b_filetest.text = "File";
+ + +
163 
+
164 
+
165  //Bottom line
+
166  tft_draw_line(0, 145, 319, 145, BLACK);
+
167  tft_print_line(10, 150, BLUE, TRANSPARENT, 0, "Powered by");
+
168  tft_draw_bitmap_file_unscaled(10, 165, "pixy_small.bmp");
+
169  tft_draw_bitmap_file_unscaled(165, 165, "stm_small.bmp");
+
170 
+
171 }
+
const char * text
The label of the button.
Definition: button.h:61
+
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
+
void tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:50
+
uint16_t y1
Top Left Y-Coordinate of Area.
Definition: touch.h:75
+
static void b_our_tracking_cb(void *button)
Definition: screen_main.c:38
+
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
+
uint16_t x1
Top Left X-Coordinate of Area.
Definition: touch.h:74
+
BUTTON_STRUCT b_guitest
Definition: screen_main.c:29
+
static void b_photo_mode_cb(void *button)
Definition: screen_main.c:50
+
#define TRANSPARENT
Definition: tft.h:66
+
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 X_TAB
+
#define Y_SECOND
+
#define HEX(h)
Definition: tft.h:60
+
BUTTON_STRUCT b_photo_mode
Definition: screen_main.c:35
+
uint16_t y2
Bottom Right Y-Coordinate of Area.
Definition: touch.h:77
+
bool tft_draw_bitmap_file_unscaled(uint16_t x, uint16_t y, const char *filename)
Definition: tft.c:123
+
void tft_clear(uint16_t color)
Definition: tft.c:45
+
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
+
BUTTON_STRUCT b_ref_tracking
Definition: screen_main.c:34
+
static void b_guitest_cb(void *button)
Definition: screen_main.c:55
+
#define WHITE
Definition: tft.h:53
+
#define Y_FIRST
+
BUTTON_STRUCT b_filetest
Definition: screen_main.c:31
+
BUTTON_STRUCT b_our_tracking
Definition: screen_main.c:33
+
static void b_pixytest_cb(void *button)
Definition: screen_main.c:65
+
#define BLUE
Definition: tft.h:52
+
BUTTON_CALLBACK callback
Callback which is executed when the button is pressed.
Definition: button.h:58
+
static void b_ref_tracking_cb(void *button)
Definition: screen_main.c:44
+
uint8_t font
The number of the font to use.
Definition: button.h:60
+
static void b_filetest_cb(void *button)
Definition: screen_main.c:60
+
#define Y_THIRD
+
#define BUTTON_SPACING
+
BUTTON_STRUCT b_pixytest
Definition: screen_main.c:30
+
#define BLACK
Definition: tft.h:54
+

Here is the call graph for this function:
@@ -532,6 +722,23 @@ Here is the call graph for this function:
+

Definition at line 173 of file screen_main.c.

+
174 {
+ + + + + + +
181 }
+
BUTTON_STRUCT b_guitest
Definition: screen_main.c:29
+
BUTTON_STRUCT b_photo_mode
Definition: screen_main.c:35
+
BUTTON_STRUCT b_ref_tracking
Definition: screen_main.c:34
+
void gui_button_remove(BUTTON_STRUCT *button)
Definition: button.c:184
+
BUTTON_STRUCT b_filetest
Definition: screen_main.c:31
+
BUTTON_STRUCT b_our_tracking
Definition: screen_main.c:33
+
BUTTON_STRUCT b_pixytest
Definition: screen_main.c:30
+

Here is the call graph for this function:
@@ -565,6 +772,11 @@ Here is the call graph for this function:
+

Definition at line 183 of file screen_main.c.

+
184 {
+
185  //gui_button_redraw(&b_guitest); //only needed if button is overdrawn by others
+
186 }
+

Variable Documentation

@@ -578,6 +790,8 @@ Here is the call graph for this function:
+

Definition at line 31 of file screen_main.c.

+
@@ -590,6 +804,8 @@ Here is the call graph for this function:
+

Definition at line 29 of file screen_main.c.

+
@@ -602,6 +818,8 @@ Here is the call graph for this function:
+

Definition at line 33 of file screen_main.c.

+
@@ -614,6 +832,8 @@ Here is the call graph for this function:
+

Definition at line 35 of file screen_main.c.

+
@@ -626,6 +846,8 @@ Here is the call graph for this function:
+

Definition at line 30 of file screen_main.c.

+
@@ -638,6 +860,8 @@ Here is the call graph for this function:
+

Definition at line 34 of file screen_main.c.

+
@@ -662,16 +886,18 @@ Here is the call graph for this function:
leave,
update
}
-
static void enter(void *screen)
Definition: screen_main.c:47
-
static void leave(void *screen)
Definition: screen_main.c:148
-
static void update(void *screen)
Definition: screen_main.c:157
+
static void enter(void *screen)
Definition: screen_main.c:71
+
static void leave(void *screen)
Definition: screen_main.c:173
+
static void update(void *screen)
Definition: screen_main.c:183
+

Definition at line 189 of file screen_main.c.

+ diff --git a/screen__main_8c_source.html b/screen__main_8c_source.html new file mode 100644 index 0000000..e4708a5 --- /dev/null +++ b/screen__main_8c_source.html @@ -0,0 +1,363 @@ + + + + + + +discoverpixy: common/app/screen_main.c Source File + + + + + + + + + + +
+
+ + + + + + +
+
discoverpixy +
+
+
+ + + + + + +
+
+ + +
+ +
+ + +
+
+
+
screen_main.c
+
+
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/app/screen_main.c
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-04-27 timolang@gmail.com cf72baa Introduced a Screen (sub) module and divided app into multiple screens.
+
11 * 2015-05-10 timolang@gmail.com e2bce8f Added filesystem module, tests and implementation for it in emulator.
+
12 * 2015-05-15 timolang@gmail.com 27c09ba Redesigned main menu. Moved stuff from pixytest to a new helper file and to the new "photo mode"-screen.
+
13 * 2015-05-16 timolang@gmail.com e46314b Added Tracking Screen and implemented "Reference Tracking" and "Color Region Selection"
+
14 * 2015-06-01 aaron@duckpond.ch caa7b5c Added IRQ for user button, fixed some touchproblems.
+
15 * 2015-06-01 timolang@gmail.com 3155f42 Fixed mainscreen layout.
+
16 *
+
17 **************************************************************************************************************************************/
+
18 
+
19 #include "screen_main.h"
+
20 #include "screen_guitest.h"
+
21 #include "screen_pixytest.h"
+
22 #include "screen_filetest.h"
+
23 #include "screen_photomode.h"
+
24 #include "screen_tracking.h"
+
25 #include "button.h"
+
26 #include "tft.h"
+
27 #include "filesystem.h"
+
28 
+ + + +
32 
+ + + +
36 
+
37 
+
38 static void b_our_tracking_cb(void* button)
+
39 {
+ + +
42 }
+
43 
+
44 static void b_ref_tracking_cb(void* button)
+
45 {
+ + +
48 }
+
49 
+
50 static void b_photo_mode_cb(void* button)
+
51 {
+ +
53 }
+
54 
+
55 static void b_guitest_cb(void* button)
+
56 {
+ +
58 }
+
59 
+
60 static void b_filetest_cb(void* button)
+
61 {
+ +
63 }
+
64 
+
65 static void b_pixytest_cb(void* button)
+
66 {
+ +
68 }
+
69 
+
70 
+
71 static void enter(void* screen)
+
72 {
+ +
74 
+
75  //Heading
+
76  tft_print_line(10, 10, BLUE, TRANSPARENT, 1, "Discoverpixy");
+
77  tft_draw_line(0, 40, 319, 40, BLACK);
+
78 
+
79 #define X_TAB 97
+
80 #define BUTTON_SPACING 7
+
81 
+
82  //First line of buttons
+
83 #define Y_FIRST 60
+
84  tft_print_line(10, Y_FIRST, BLACK, TRANSPARENT, 0, "Tracking:");
+
85 
+
86  b_our_tracking.base.x1 = X_TAB; //Start X of Button
+
87  b_our_tracking.base.y1 = Y_FIRST - 3; //Start Y of Button
+
88  b_our_tracking.base.x2 = AUTO; //Auto Calculate X2 with String Width
+
89  b_our_tracking.base.y2 = AUTO; //Auto Calculate Y2 with String Height
+
90  b_our_tracking.txtcolor = WHITE; //Set foreground color
+
91  b_our_tracking.bgcolor = HEX(0xE30535); //Set background color (Don't take 255 or 0 on at least one channel, to make shadows possible)
+
92  b_our_tracking.font = 0; //Select Font
+
93  b_our_tracking.text = "Our Tracking"; //Set Text (For formatted strings take sprintf)
+
94  b_our_tracking.callback = b_our_tracking_cb; //Call b_our_tracking when the button get's pressed
+
95  gui_button_add(&b_our_tracking); //Register Button (and run the callback from now on)
+
96 
+
97 
+
98  b_ref_tracking.base.x1 = b_our_tracking.base.x2 + BUTTON_SPACING;
+
99  b_ref_tracking.base.y1 = Y_FIRST - 3;
+
100  b_ref_tracking.base.x2 = AUTO;
+
101  b_ref_tracking.base.y2 = AUTO;
+
102  b_ref_tracking.txtcolor = WHITE;
+
103  b_ref_tracking.bgcolor = HEX(0xFF2151);
+
104  b_ref_tracking.font = 0;
+
105  b_ref_tracking.text = "Ref Tracking";
+
106  b_ref_tracking.callback = b_ref_tracking_cb;
+
107  gui_button_add(&b_ref_tracking);
+
108 
+
109  //Second line of buttons
+
110 #define Y_SECOND Y_FIRST+25
+
111  tft_print_line(10, Y_SECOND, BLACK, TRANSPARENT, 0, "Photo mode:");
+
112 
+
113  b_photo_mode.base.x1 = X_TAB;
+
114  b_photo_mode.base.y1 = Y_SECOND - 3;
+
115  b_photo_mode.base.x2 = AUTO;
+
116  b_photo_mode.base.y2 = AUTO;
+
117  b_photo_mode.txtcolor = WHITE;
+
118  b_photo_mode.bgcolor = HEX(0x21B1FF);
+
119  b_photo_mode.font = 0;
+
120  b_photo_mode.text = "Photo Mode";
+
121  b_photo_mode.callback = b_photo_mode_cb;
+
122  gui_button_add(&b_photo_mode);
+
123 
+
124 
+
125  //Third line of buttons
+
126 #define Y_THIRD Y_SECOND+25
+
127  tft_print_line(10, Y_THIRD, BLACK, TRANSPARENT, 0, "Tests:");
+
128 
+
129  b_guitest.base.x1 = X_TAB;
+
130  b_guitest.base.y1 = Y_THIRD - 3;
+
131  b_guitest.base.x2 = AUTO;
+
132  b_guitest.base.y2 = AUTO;
+
133  b_guitest.txtcolor = BLACK;
+
134  b_guitest.bgcolor = HEX(0x00FA21);
+
135  b_guitest.font = 0;
+
136  b_guitest.text = "Gui & Tft";
+
137  b_guitest.callback = b_guitest_cb;
+
138  gui_button_add(&b_guitest);
+
139 
+
140 
+
141  b_pixytest.base.x1 = b_guitest.base.x2 + BUTTON_SPACING;
+
142  b_pixytest.base.y1 = Y_THIRD - 3;
+
143  b_pixytest.base.x2 = AUTO;
+
144  b_pixytest.base.y2 = AUTO;
+
145  b_pixytest.txtcolor = BLACK;
+
146  b_pixytest.bgcolor = HEX(0x00FA96);
+
147  b_pixytest.font = 0;
+
148  b_pixytest.text = "Pixy";
+
149  b_pixytest.callback = b_pixytest_cb;
+
150  gui_button_add(&b_pixytest);
+
151 
+
152 
+
153  b_filetest.base.x1 = b_pixytest.base.x2 + BUTTON_SPACING;
+
154  b_filetest.base.y1 = Y_THIRD - 3;
+
155  b_filetest.base.x2 = AUTO;
+
156  b_filetest.base.y2 = AUTO;
+
157  b_filetest.txtcolor = BLACK;
+
158  b_filetest.bgcolor = HEX(0x00FAC4);
+
159  b_filetest.font = 0;
+
160  b_filetest.text = "File";
+
161  b_filetest.callback = b_filetest_cb;
+
162  gui_button_add(&b_filetest);
+
163 
+
164 
+
165  //Bottom line
+
166  tft_draw_line(0, 145, 319, 145, BLACK);
+
167  tft_print_line(10, 150, BLUE, TRANSPARENT, 0, "Powered by");
+
168  tft_draw_bitmap_file_unscaled(10, 165, "pixy_small.bmp");
+
169  tft_draw_bitmap_file_unscaled(165, 165, "stm_small.bmp");
+
170 
+
171 }
+
172 
+
173 static void leave(void* screen)
+
174 {
+
175  gui_button_remove(&b_our_tracking);
+
176  gui_button_remove(&b_ref_tracking);
+
177  gui_button_remove(&b_photo_mode);
+
178  gui_button_remove(&b_guitest);
+
179  gui_button_remove(&b_pixytest);
+
180  gui_button_remove(&b_filetest);
+
181 }
+
182 
+
183 static void update(void* screen)
+
184 {
+
185  //gui_button_redraw(&b_guitest); //only needed if button is overdrawn by others
+
186 }
+
187 
+
188 
+ +
190  enter,
+
191  leave,
+
192  update
+
193 };
+
194 
+
195 
+ +
197 {
+
198  return &screen;
+
199 }
+
const char * text
The label of the button.
Definition: button.h:61
+
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
+
static SCREEN_STRUCT screen
Definition: screen_main.c:189
+
void tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:50
+
static void enter(void *screen)
Definition: screen_main.c:71
+
uint16_t y1
Top Left Y-Coordinate of Area.
Definition: touch.h:75
+
static void b_our_tracking_cb(void *button)
Definition: screen_main.c:38
+ +
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
+
void tracking_set_mode(enum Tracking_Implementation impl)
+
static void leave(void *screen)
Definition: screen_main.c:173
+
uint16_t x1
Top Left X-Coordinate of Area.
Definition: touch.h:74
+
BUTTON_STRUCT b_guitest
Definition: screen_main.c:29
+
static void b_photo_mode_cb(void *button)
Definition: screen_main.c:50
+
#define TRANSPARENT
Definition: tft.h:66
+
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 X_TAB
+
#define Y_SECOND
+ +
#define HEX(h)
Definition: tft.h:60
+
BUTTON_STRUCT b_photo_mode
Definition: screen_main.c:35
+
uint16_t y2
Bottom Right Y-Coordinate of Area.
Definition: touch.h:77
+
Pixy's internal tracking implementation.
+ +
SCREEN_STRUCT * get_screen_filetest()
+
bool tft_draw_bitmap_file_unscaled(uint16_t x, uint16_t y, const char *filename)
Definition: tft.c:123
+
SCREEN_STRUCT * get_screen_pixytest()
+ +
static void update(void *screen)
Definition: screen_main.c:183
+
SCREEN_STRUCT * get_screen_main()
Definition: screen_main.c:196
+
void tft_clear(uint16_t color)
Definition: tft.c:45
+
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
+ +
BUTTON_STRUCT b_ref_tracking
Definition: screen_main.c:34
+
void gui_button_remove(BUTTON_STRUCT *button)
Definition: button.c:184
+
static void b_guitest_cb(void *button)
Definition: screen_main.c:55
+
bool gui_screen_navigate(SCREEN_STRUCT *screen)
Definition: screen.c:74
+ +
SCREEN_STRUCT * get_screen_photomode()
+
#define WHITE
Definition: tft.h:53
+
#define Y_FIRST
+
BUTTON_STRUCT b_filetest
Definition: screen_main.c:31
+ +
BUTTON_STRUCT b_our_tracking
Definition: screen_main.c:33
+
SCREEN_STRUCT * get_screen_tracking()
+
static void b_pixytest_cb(void *button)
Definition: screen_main.c:65
+ +
#define BLUE
Definition: tft.h:52
+
SCREEN_STRUCT * get_screen_guitest()
+ +
BUTTON_CALLBACK callback
Callback which is executed when the button is pressed.
Definition: button.h:58
+
static void b_ref_tracking_cb(void *button)
Definition: screen_main.c:44
+
uint8_t font
The number of the font to use.
Definition: button.h:60
+
Our own tracking PID implementation.
+
static void b_filetest_cb(void *button)
Definition: screen_main.c:60
+
#define Y_THIRD
+
#define BUTTON_SPACING
+
BUTTON_STRUCT b_pixytest
Definition: screen_main.c:30
+ +
#define BLACK
Definition: tft.h:54
+ +
+ + + + diff --git a/screen__main_8h.html b/screen__main_8h.html index 602b63a..55c295a 100644 --- a/screen__main_8h.html +++ b/screen__main_8h.html @@ -117,7 +117,7 @@ Functions diff --git a/screen__main_8h_source.html b/screen__main_8h_source.html index b491fc1..5d87d40 100644 --- a/screen__main_8h_source.html +++ b/screen__main_8h_source.html @@ -89,23 +89,40 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
screen_main.h
-Go to the documentation of this file.
1 #include "screen.h"
-
2 
-
7 
-
13 
-
14 
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/app/screen_main.h
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-04-27 timolang@gmail.com cf72baa Introduced a Screen (sub) module and divided app into multiple screens.
+
11 * 2015-05-10 timolang@gmail.com 21edc56 Added doxyfile (doxygen) for the common folder. Started with doxygen comments for app and tft module.
+
12 * 2015-05-11 timolang@gmail.com 08d9fe0 More work on doxygen module structure
+
13 * 2015-05-12 timolang@gmail.com 1402598 Added doxygen stuff for button module and some minor changes to touch, screen_main and tft module.
+
14 * 2015-05-15 timolang@gmail.com 9a16865 Added doxgen comments to filesyste, checkbox, numupdown and screen module. And some minor changes to the other modules.
+
15 *
+
16 **************************************************************************************************************************************/
+
17 
+
18 #include "screen.h"
19 
-
25 
-
26 
- -
33 
+
24 
+
30 
+
31 
+
36 
+
42 
+
43 
+ +
50 
-
SCREEN_STRUCT * get_screen_main()
Definition: screen_main.c:169
-
Definition: screen.h:34
+
SCREEN_STRUCT * get_screen_main()
Definition: screen_main.c:196
+
diff --git a/screen__photomode_8c.html b/screen__photomode_8c.html index b24ada2..24a580a 100644 --- a/screen__photomode_8c.html +++ b/screen__photomode_8c.html @@ -107,7 +107,9 @@ Include dependency graph for screen_photomode.c:
- + +

Go to the source code of this file.

+
@@ -135,7 +137,7 @@ Variables - + @@ -167,6 +169,14 @@ Variables

Functions

static void b_back_cb (void *button)
 
static TOUCH_AREA_STRUCT a_area
 
static bool subMenu =false
static bool subMenu = false
 
static POINT_STRUCT pixy_pos
 
+

Definition at line 33 of file screen_photomode.c.

+
34 {
+
35  subMenu = false; //we're not entering a submenu
+
36  gui_screen_back(); //navigate back to the previous screen
+
37 }
+
static bool subMenu
+
bool gui_screen_back()
Definition: screen.c:85
+

Here is the call graph for this function:
@@ -209,6 +219,15 @@ Here is the caller graph for this function:
+

Definition at line 40 of file screen_photomode.c.

+
41 {
+
42  subMenu = true; //we're entering a submenu
+
43  gui_screen_navigate(get_screen_photomodesave()); //navigate to the save screen
+
44 }
+
SCREEN_STRUCT * get_screen_photomodesave()
+
static bool subMenu
+
bool gui_screen_navigate(SCREEN_STRUCT *screen)
Definition: screen.c:74
+

Here is the call graph for this function:
@@ -251,6 +270,94 @@ Here is the caller graph for this function:
+

Definition at line 107 of file screen_photomode.c.

+
108 {
+
109  tft_clear(WHITE);
+
110 
+
111  tft_print_line(5, 5, BLACK, TRANSPARENT, 0, "Drag the image around and ");
+
112 
+
113  //Back button
+
114  b_back.base.x1 = 5; //Start X of Button
+
115  b_back.base.y1 = 19; //Start Y of Button
+
116  b_back.base.x2 = AUTO; //Auto Calculate X2 with String Width
+
117  b_back.base.y2 = AUTO; //Auto Calculate Y2 with String Height
+
118  b_back.txtcolor = WHITE; //Set foreground color
+
119  b_back.bgcolor = HEX(0xAE1010); //Set background color (Don't take 255 or 0 on at least one channel, to make shadows possible)
+
120  b_back.font = 0; //Select Font
+
121  b_back.text = "Back"; //Set Text (For formatted strings take sprintf)
+
122  b_back.callback = b_back_cb; //Call b_back_cb as Callback
+
123  gui_button_add(&b_back); //Register Button (and run the callback from now on)
+
124 
+
125  //Save button
+
126  b_save.base.x1 = 190;
+
127  b_save.base.y1 = 3;
+
128  b_save.base.x2 = AUTO;
+
129  b_save.base.y2 = AUTO;
+ +
131  b_save.bgcolor = HEX(0x1010AE);
+
132  b_save.font = 0;
+
133  b_save.text = "Save it!";
+ + +
136 
+
137  //Frame Coordinates: topleft = (1,40); bottomright = (318,238)
+
138  //Leave a 10px border for the area
+
139 
+
140  //Area to drag the image around
+ +
142  a_area.x1 = 11;
+
143  a_area.y1 = 50;
+
144  a_area.x2 = 308;
+
145  a_area.y2 = 228;
+ + +
148 
+
149  //Pixy stuff
+
150  pixy_connected = (pixy_init() == 0); //try to connect to pixy
+
151 
+
152  if (pixy_connected && !subMenu) { //pixy is connected, but we are not coming from a submenu
+
153  pixy_pos.x = pixy_pos.y = 500; //reset servo positions to center
+
154  }
+
155 }
+
bool touch_register_area(TOUCH_AREA_STRUCT *area)
Definition: touch.c:181
+
const char * text
The label of the button.
Definition: button.h:61
+
Receive an event when the pen moves inside the region (pen is down)
Definition: touch.h:58
+
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
+
Receive an event when the pen goes down inside the region.
Definition: touch.h:54
+
Receive an event when the pen goes up inside the region.
Definition: touch.h:55
+
uint16_t y1
Top Left Y-Coordinate of Area.
Definition: touch.h:75
+
uint16_t y
The Y-Coordinate of the point.
Definition: touch.h:88
+
static void touchCB(void *touchArea, TOUCH_ACTION triggeredAction)
+
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
+
uint16_t x
The X-Coordinate of the point.
Definition: touch.h:87
+
static bool subMenu
+
uint16_t x1
Top Left X-Coordinate of Area.
Definition: touch.h:74
+
#define TRANSPARENT
Definition: tft.h:66
+
static BUTTON_STRUCT b_back
+
uint16_t bgcolor
The 16-bit background color of the button.
Definition: button.h:57
+
static POINT_STRUCT pixy_pos
+
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
+
static void b_save_cb(void *button)
+
#define HEX(h)
Definition: tft.h:60
+
uint16_t y2
Bottom Right Y-Coordinate of Area.
Definition: touch.h:77
+
static BUTTON_STRUCT b_save
+
TOUCH_CALLBACK callback
Callback which is executed when an event occurred in this Area.
Definition: touch.h:78
+
void tft_clear(uint16_t color)
Definition: tft.c:45
+
static void b_back_cb(void *button)
+
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
+
static TOUCH_AREA_STRUCT a_area
+
Receive an event when the pen enters the region (pen was down before)
Definition: touch.h:56
+
#define WHITE
Definition: tft.h:53
+
int pixy_init()
Creates a connection with Pixy and listens for Pixy messages.
+
TOUCH_ACTION hookedActions
Actions to listen to.
Definition: touch.h:73
+
static bool pixy_connected
+
BUTTON_CALLBACK callback
Callback which is executed when the button is pressed.
Definition: button.h:58
+
uint8_t font
The number of the font to use.
Definition: button.h:60
+
#define BLACK
Definition: tft.h:54
+
Receive an event when the pen leaves the region (pen was inside region before)
Definition: touch.h:57
+

Here is the call graph for this function:
@@ -284,6 +391,19 @@ Here is the call graph for this function:
+

Definition at line 158 of file screen_photomode.c.

+
159 {
+
160  //remove buttons and touch area.
+ + + +
164 }
+
static BUTTON_STRUCT b_back
+
void touch_unregister_area(TOUCH_AREA_STRUCT *area)
Definition: touch.c:195
+
static BUTTON_STRUCT b_save
+
static TOUCH_AREA_STRUCT a_area
+
void gui_button_remove(BUTTON_STRUCT *button)
Definition: button.c:184
+

Here is the call graph for this function:
@@ -327,6 +447,74 @@ Here is the call graph for this function:
+

Definition at line 50 of file screen_photomode.c.

+
51 {
+
52  POINT_STRUCT p = touch_get_last_point(); //get the last touched point
+
53 
+
54  switch (triggeredAction) {
+
55  case PEN_ENTER:
+
56  case PEN_DOWN:
+
57  old_pos = p; //If the user "newly" enters the touch area, we set the "last" position to the current
+
58  break;
+
59 
+
60  case PEN_MOVE: { //the user is moving around, he entered the screen a while ago (old_pos is set)
+
61  int16_t deltaX = p.x - old_pos.x; //Calculate x difference between last and current touch
+
62  int16_t deltaY = p.y - old_pos.y; //Calculate y difference between last and current touch
+
63  old_pos = p; //store the current touch point for the next time
+
64 
+
65  //printf("%d %d\n",deltaX,deltaY);
+
66  if (pixy_connected) {
+
67  //Calculate new servo coordinates. 2 is just a proportional factor
+
68  int16_t new_x = pixy_pos.x + deltaX * 2;
+
69  int16_t new_y = pixy_pos.y - deltaY * 2;
+
70 
+
71  //check limits
+
72  if (new_x < 0) {
+
73  new_x = 0;
+
74  }
+
75 
+
76  if (new_x > 1000) {
+
77  new_x = 1000;
+
78  }
+
79 
+
80  if (new_y < 0) {
+
81  new_y = 0;
+
82  }
+
83 
+
84  if (new_y > 1000) {
+
85  new_y = 1000;
+
86  }
+
87 
+
88  //set pixy_pos so that the main routine can send it to the servos
+
89  pixy_pos.x = new_x;
+
90  pixy_pos.y = new_y;
+
91  }
+
92  }
+
93  break;
+
94 
+
95  case PEN_UP:
+
96  case PEN_LEAVE:
+
97  //printf("Leave/up\n");
+
98  break;
+
99 
+
100  default:
+
101  break;
+
102  }
+
103 
+
104 }
+
Receive an event when the pen moves inside the region (pen is down)
Definition: touch.h:58
+
Receive an event when the pen goes down inside the region.
Definition: touch.h:54
+
Receive an event when the pen goes up inside the region.
Definition: touch.h:55
+
uint16_t y
The Y-Coordinate of the point.
Definition: touch.h:88
+
uint16_t x
The X-Coordinate of the point.
Definition: touch.h:87
+
static POINT_STRUCT pixy_pos
+
Receive an event when the pen enters the region (pen was down before)
Definition: touch.h:56
+
POINT_STRUCT touch_get_last_point()
Definition: touch.c:211
+
static POINT_STRUCT old_pos
+
static bool pixy_connected
+ +
Receive an event when the pen leaves the region (pen was inside region before)
Definition: touch.h:57
+

Here is the call graph for this function:
@@ -369,6 +557,45 @@ Here is the caller graph for this function:
+

Definition at line 168 of file screen_photomode.c.

+
169 {
+
170  //Note: The only way to detect that pixy has been disconnected is if a command fails. There's no pixy_is_connected method yet :'(
+
171 
+
172  if (!pixy_connected) { //Pixy not connected
+
173  pixy_close(); //Ensure that all pixy resources are freed (failsafe)
+
174 
+
175  if (pixy_init() == 0) { //try to connect to pixy
+
176  pixy_connected = true;
+
177 
+
178  if (!subMenu) { //we're not coming from a submenu
+
179  pixy_pos.x = pixy_pos.y = 500; //reset servo positions to center
+
180  }
+
181 
+
182  printf("pixy (re)initialized\n");
+
183  }
+
184  }
+
185 
+
186  if (pixy_connected) { //If we are connected (now)
+
187  pixy_service(); //Handle pending pixy events (e.g. color info retrival)
+
188 
+
189  pixy_render_full_frame(1, 40); //render the pixy video at point (1,40)
+
190 
+
191  //set the servo positions to the coordinates form the touch interrupt
+ + +
194  }
+
195 }
+
uint16_t y
The Y-Coordinate of the point.
Definition: touch.h:88
+
uint16_t x
The X-Coordinate of the point.
Definition: touch.h:87
+
static bool subMenu
+
static POINT_STRUCT pixy_pos
+
int pixy_service()
+
int pixy_init()
Creates a connection with Pixy and listens for Pixy messages.
+
static bool pixy_connected
+
int pixy_rcs_set_position(uint8_t channel, uint16_t position)
Set pixy servo axis position.
+
void pixy_close()
Terminates connection with Pixy.
+
int pixy_render_full_frame(uint16_t x, uint16_t y)
Definition: pixy_frame.c:25
+

Here is the call graph for this function:
@@ -399,6 +626,8 @@ Here is the call graph for this function:
+

Definition at line 29 of file screen_photomode.c.

+
@@ -419,6 +648,8 @@ Here is the call graph for this function:
+

Definition at line 27 of file screen_photomode.c.

+
@@ -439,6 +670,8 @@ Here is the call graph for this function:
+

Definition at line 28 of file screen_photomode.c.

+
@@ -459,6 +692,8 @@ Here is the call graph for this function:
+

Definition at line 47 of file screen_photomode.c.

+
@@ -479,6 +714,8 @@ Here is the call graph for this function:
+

Definition at line 25 of file screen_photomode.c.

+
@@ -499,6 +736,8 @@ Here is the call graph for this function:
+

Definition at line 46 of file screen_photomode.c.

+
@@ -523,10 +762,12 @@ Here is the call graph for this function:
leave,
update
}
-
static void leave(void *screen)
Definition: screen_photomode.c:122
-
static void enter(void *screen)
Definition: screen_photomode.c:73
-
static void update(void *screen)
Definition: screen_photomode.c:131
+
static void leave(void *screen)
+
static void enter(void *screen)
+
static void update(void *screen)
+

Definition at line 198 of file screen_photomode.c.

+ @@ -537,7 +778,7 @@ Here is the call graph for this function: - +
bool subMenu =falsebool subMenu = false
@@ -547,12 +788,14 @@ Here is the call graph for this function:
+

Definition at line 30 of file screen_photomode.c.

+
diff --git a/screen__photomode_8c_source.html b/screen__photomode_8c_source.html new file mode 100644 index 0000000..3e857a6 --- /dev/null +++ b/screen__photomode_8c_source.html @@ -0,0 +1,375 @@ + + + + + + +discoverpixy: common/app/screen_photomode.c Source File + + + + + + + + + + +
+
+ + + + + + +
+
discoverpixy +
+
+
+ + + + + + +
+
+ + +
+ +
+ + +
+
+
+
screen_photomode.c
+
+
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/app/screen_photomode.c
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-05-15 timolang@gmail.com 27c09ba Redesigned main menu. Moved stuff from pixytest to a new helper file and to the new "photo mode"-screen.
+
11 * 2015-05-16 timolang@gmail.com 62006e0 Documented pixy_helper and implemented/finished photo-mode screens! Snap some shots!
+
12 * 2015-06-07 timolang@gmail.com c87220d Renamed pixy_helper to pixy_frame. Updated docu of appliaction. added doxygen comments to pixy_{frame,control}.h
+
13 *
+
14 **************************************************************************************************************************************/
+
15 
+
16 #include "screen_photomode.h"
+
17 #include "screen_photomode_save.h"
+
18 #include "button.h"
+
19 #include "tft.h"
+
20 #include "touch.h"
+
21 #include "pixy.h"
+
22 #include "system.h"
+
23 #include "pixy_frame.h"
+
24 
+
25 static bool pixy_connected = false; //Whether or not the pixy cam is currently connected
+
26 
+
27 static BUTTON_STRUCT b_back; //Button to navigate back
+
28 static BUTTON_STRUCT b_save; //Button to save the current image
+
29 static TOUCH_AREA_STRUCT a_area; //Touch Area, where the frame is drawn. Used to drag the image around
+
30 static bool subMenu = false; //Whether or not we left the current screen for a submenu
+
31 
+
32 //Callback for when the user presses the "back" button
+
33 static void b_back_cb(void* button)
+
34 {
+
35  subMenu = false; //we're not entering a submenu
+
36  gui_screen_back(); //navigate back to the previous screen
+
37 }
+
38 
+
39 //Callback for when the user presses the "save" button
+
40 static void b_save_cb(void* button)
+
41 {
+
42  subMenu = true; //we're entering a submenu
+
43  gui_screen_navigate(get_screen_photomodesave()); //navigate to the save screen
+
44 }
+
45 
+
46 static POINT_STRUCT pixy_pos; //The current position of pixy's servos
+
47 static POINT_STRUCT old_pos; //The last touch position on the screen
+
48 
+
49 //Callback for when the user drags the image around
+
50 static void touchCB(void* touchArea, TOUCH_ACTION triggeredAction)
+
51 {
+
52  POINT_STRUCT p = touch_get_last_point(); //get the last touched point
+
53 
+
54  switch (triggeredAction) {
+
55  case PEN_ENTER:
+
56  case PEN_DOWN:
+
57  old_pos = p; //If the user "newly" enters the touch area, we set the "last" position to the current
+
58  break;
+
59 
+
60  case PEN_MOVE: { //the user is moving around, he entered the screen a while ago (old_pos is set)
+
61  int16_t deltaX = p.x - old_pos.x; //Calculate x difference between last and current touch
+
62  int16_t deltaY = p.y - old_pos.y; //Calculate y difference between last and current touch
+
63  old_pos = p; //store the current touch point for the next time
+
64 
+
65  //printf("%d %d\n",deltaX,deltaY);
+
66  if (pixy_connected) {
+
67  //Calculate new servo coordinates. 2 is just a proportional factor
+
68  int16_t new_x = pixy_pos.x + deltaX * 2;
+
69  int16_t new_y = pixy_pos.y - deltaY * 2;
+
70 
+
71  //check limits
+
72  if (new_x < 0) {
+
73  new_x = 0;
+
74  }
+
75 
+
76  if (new_x > 1000) {
+
77  new_x = 1000;
+
78  }
+
79 
+
80  if (new_y < 0) {
+
81  new_y = 0;
+
82  }
+
83 
+
84  if (new_y > 1000) {
+
85  new_y = 1000;
+
86  }
+
87 
+
88  //set pixy_pos so that the main routine can send it to the servos
+
89  pixy_pos.x = new_x;
+
90  pixy_pos.y = new_y;
+
91  }
+
92  }
+
93  break;
+
94 
+
95  case PEN_UP:
+
96  case PEN_LEAVE:
+
97  //printf("Leave/up\n");
+
98  break;
+
99 
+
100  default:
+
101  break;
+
102  }
+
103 
+
104 }
+
105 
+
106 //Callback for when the screen is entered/loaded
+
107 static void enter(void* screen)
+
108 {
+
109  tft_clear(WHITE);
+
110 
+
111  tft_print_line(5, 5, BLACK, TRANSPARENT, 0, "Drag the image around and ");
+
112 
+
113  //Back button
+
114  b_back.base.x1 = 5; //Start X of Button
+
115  b_back.base.y1 = 19; //Start Y of Button
+
116  b_back.base.x2 = AUTO; //Auto Calculate X2 with String Width
+
117  b_back.base.y2 = AUTO; //Auto Calculate Y2 with String Height
+
118  b_back.txtcolor = WHITE; //Set foreground color
+
119  b_back.bgcolor = HEX(0xAE1010); //Set background color (Don't take 255 or 0 on at least one channel, to make shadows possible)
+
120  b_back.font = 0; //Select Font
+
121  b_back.text = "Back"; //Set Text (For formatted strings take sprintf)
+
122  b_back.callback = b_back_cb; //Call b_back_cb as Callback
+
123  gui_button_add(&b_back); //Register Button (and run the callback from now on)
+
124 
+
125  //Save button
+
126  b_save.base.x1 = 190;
+
127  b_save.base.y1 = 3;
+
128  b_save.base.x2 = AUTO;
+
129  b_save.base.y2 = AUTO;
+
130  b_save.txtcolor = WHITE;
+
131  b_save.bgcolor = HEX(0x1010AE);
+
132  b_save.font = 0;
+
133  b_save.text = "Save it!";
+
134  b_save.callback = b_save_cb;
+
135  gui_button_add(&b_save);
+
136 
+
137  //Frame Coordinates: topleft = (1,40); bottomright = (318,238)
+
138  //Leave a 10px border for the area
+
139 
+
140  //Area to drag the image around
+ +
142  a_area.x1 = 11;
+
143  a_area.y1 = 50;
+
144  a_area.x2 = 308;
+
145  a_area.y2 = 228;
+
146  a_area.callback = touchCB;
+
147  touch_register_area(&a_area);
+
148 
+
149  //Pixy stuff
+
150  pixy_connected = (pixy_init() == 0); //try to connect to pixy
+
151 
+
152  if (pixy_connected && !subMenu) { //pixy is connected, but we are not coming from a submenu
+
153  pixy_pos.x = pixy_pos.y = 500; //reset servo positions to center
+
154  }
+
155 }
+
156 
+
157 //Callback for when the screen is left/unloaded
+
158 static void leave(void* screen)
+
159 {
+
160  //remove buttons and touch area.
+
161  gui_button_remove(&b_back);
+
162  gui_button_remove(&b_save);
+
163  touch_unregister_area(&a_area);
+
164 }
+
165 
+
166 //Callback for when the screen should be updated
+
167 //This is the main loop of the screen. This method will be called repeatedly
+
168 static void update(void* screen)
+
169 {
+
170  //Note: The only way to detect that pixy has been disconnected is if a command fails. There's no pixy_is_connected method yet :'(
+
171 
+
172  if (!pixy_connected) { //Pixy not connected
+
173  pixy_close(); //Ensure that all pixy resources are freed (failsafe)
+
174 
+
175  if (pixy_init() == 0) { //try to connect to pixy
+
176  pixy_connected = true;
+
177 
+
178  if (!subMenu) { //we're not coming from a submenu
+
179  pixy_pos.x = pixy_pos.y = 500; //reset servo positions to center
+
180  }
+
181 
+
182  printf("pixy (re)initialized\n");
+
183  }
+
184  }
+
185 
+
186  if (pixy_connected) { //If we are connected (now)
+
187  pixy_service(); //Handle pending pixy events (e.g. color info retrival)
+
188 
+
189  pixy_render_full_frame(1, 40); //render the pixy video at point (1,40)
+
190 
+
191  //set the servo positions to the coordinates form the touch interrupt
+
192  pixy_rcs_set_position(0, pixy_pos.x);
+
193  pixy_rcs_set_position(1, pixy_pos.y);
+
194  }
+
195 }
+
196 
+
197 //Declare screen callbacks
+ +
199  enter,
+
200  leave,
+
201  update
+
202 };
+
203 
+
204 
+ +
206 {
+
207  return &screen;
+
208 }
+
TOUCH_ACTION
Definition: touch.h:52
+
bool touch_register_area(TOUCH_AREA_STRUCT *area)
Definition: touch.c:181
+
const char * text
The label of the button.
Definition: button.h:61
+
Receive an event when the pen moves inside the region (pen is down)
Definition: touch.h:58
+
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
+
Receive an event when the pen goes down inside the region.
Definition: touch.h:54
+
Receive an event when the pen goes up inside the region.
Definition: touch.h:55
+
SCREEN_STRUCT * get_screen_photomodesave()
+
uint16_t y1
Top Left Y-Coordinate of Area.
Definition: touch.h:75
+
uint16_t y
The Y-Coordinate of the point.
Definition: touch.h:88
+
static void touchCB(void *touchArea, TOUCH_ACTION triggeredAction)
+ +
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
+
uint16_t x
The X-Coordinate of the point.
Definition: touch.h:87
+
static bool subMenu
+
uint16_t x1
Top Left X-Coordinate of Area.
Definition: touch.h:74
+ +
#define TRANSPARENT
Definition: tft.h:66
+
static BUTTON_STRUCT b_back
+
uint16_t bgcolor
The 16-bit background color of the button.
Definition: button.h:57
+
static POINT_STRUCT pixy_pos
+
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
+
static SCREEN_STRUCT screen
+
void touch_unregister_area(TOUCH_AREA_STRUCT *area)
Definition: touch.c:195
+
static void b_save_cb(void *button)
+
#define HEX(h)
Definition: tft.h:60
+ +
uint16_t y2
Bottom Right Y-Coordinate of Area.
Definition: touch.h:77
+
static void leave(void *screen)
+
int pixy_service()
+ +
static BUTTON_STRUCT b_save
+ +
TOUCH_CALLBACK callback
Callback which is executed when an event occurred in this Area.
Definition: touch.h:78
+ +
void tft_clear(uint16_t color)
Definition: tft.c:45
+
static void b_back_cb(void *button)
+
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
+
static TOUCH_AREA_STRUCT a_area
+ +
void gui_button_remove(BUTTON_STRUCT *button)
Definition: button.c:184
+
Receive an event when the pen enters the region (pen was down before)
Definition: touch.h:56
+
bool gui_screen_navigate(SCREEN_STRUCT *screen)
Definition: screen.c:74
+ +
static void enter(void *screen)
+
SCREEN_STRUCT * get_screen_photomode()
+
#define WHITE
Definition: tft.h:53
+
POINT_STRUCT touch_get_last_point()
Definition: touch.c:211
+
static POINT_STRUCT old_pos
+ +
int pixy_init()
Creates a connection with Pixy and listens for Pixy messages.
+
TOUCH_ACTION hookedActions
Actions to listen to.
Definition: touch.h:73
+
static bool pixy_connected
+
int pixy_rcs_set_position(uint8_t channel, uint16_t position)
Set pixy servo axis position.
+
static void update(void *screen)
+ + + +
void pixy_close()
Terminates connection with Pixy.
+
BUTTON_CALLBACK callback
Callback which is executed when the button is pressed.
Definition: button.h:58
+
int pixy_render_full_frame(uint16_t x, uint16_t y)
Definition: pixy_frame.c:25
+
bool gui_screen_back()
Definition: screen.c:85
+
uint8_t font
The number of the font to use.
Definition: button.h:60
+
#define BLACK
Definition: tft.h:54
+
Receive an event when the pen leaves the region (pen was inside region before)
Definition: touch.h:57
+
+ + + + diff --git a/screen__photomode_8h.html b/screen__photomode_8h.html index 37d71e5..335ce21 100644 --- a/screen__photomode_8h.html +++ b/screen__photomode_8h.html @@ -117,7 +117,7 @@ Functions diff --git a/screen__photomode_8h_source.html b/screen__photomode_8h_source.html index 7df3970..55c4df7 100644 --- a/screen__photomode_8h_source.html +++ b/screen__photomode_8h_source.html @@ -89,19 +89,32 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
screen_photomode.h
-Go to the documentation of this file.
1 #include "screen.h"
-
2 
-
7 
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/app/screen_photomode.h
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-05-15 timolang@gmail.com 27c09ba Redesigned main menu. Moved stuff from pixytest to a new helper file and to the new "photo mode"-screen.
+
11 *
+
12 **************************************************************************************************************************************/
13 
- +
14 #include "screen.h"
+
15 
20 
+
26 
+ +
33 
-
Definition: screen.h:34
-
SCREEN_STRUCT * get_screen_photomode()
Definition: screen_photomode.c:164
+ +
SCREEN_STRUCT * get_screen_photomode()
diff --git a/screen__photomode__save_8c.html b/screen__photomode__save_8c.html index af4969a..1823a5d 100644 --- a/screen__photomode__save_8c.html +++ b/screen__photomode__save_8c.html @@ -112,7 +112,9 @@ Include dependency graph for screen_photomode_save.c:
- + +

Go to the source code of this file.

+
@@ -233,6 +235,16 @@ Variables

Data Structures

struct  FILE_LIST_ENTRY_S
+

Definition at line 36 of file screen_photomode_save.c.

+
36 {init, error, showlist, picking, saving, done} state; //Current state of the screen state machine
+ + + + +
static enum @0 state
+ + +

Function Documentation

@@ -258,6 +270,12 @@ Variables
+

Definition at line 30 of file screen_photomode_save.c.

+
31 {
+ +
33 }
+
bool gui_screen_back()
Definition: screen.c:85
+

Here is the call graph for this function:
@@ -300,6 +318,55 @@ Here is the caller graph for this function:
+

Definition at line 108 of file screen_photomode_save.c.

+
109 {
+
110  tft_clear(WHITE);
+
111 
+
112 
+
113 #define X_OFS 5
+
114 
+
115  //Back button
+
116  b_back.base.x1 = X_OFS; //Start X of Button
+
117  b_back.base.y1 = 210; //Start Y of Button
+
118  b_back.base.x2 = AUTO; //Auto Calculate X2 with String Width
+
119  b_back.base.y2 = AUTO; //Auto Calculate Y2 with String Height
+
120  b_back.txtcolor = WHITE; //Set foreground color
+
121  b_back.bgcolor = HEX(0xAE1010); //Set background color (Don't take 255 or 0 on at least one channel, to make shadows possible)
+
122  b_back.font = 0; //Select Font
+
123  b_back.text = "Back"; //Set Text (For formatted strings take sprintf)
+
124  b_back.callback = b_back_cb; //Call b_back_cb as Callback
+
125  gui_button_add(&b_back); //Register Button (and run the callback from now on)
+
126 
+
127  state = init; //Start with the init state
+
128  fontheight = tft_font_height(0) + 2; //Save the height of the used font, for fast access
+
129  files_ok = NULL; //initialize the linked list with 0 elements
+
130  num_files_ok = 0; //we have zero! elements
+
131 }
+
uint8_t tft_font_height(uint8_t fontnum)
Definition: tft.c:87
+
const char * text
The label of the button.
Definition: button.h:61
+
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
+
uint16_t y1
Top Left Y-Coordinate of Area.
Definition: touch.h:75
+
#define X_OFS
+
bool gui_button_add(BUTTON_STRUCT *button)
Definition: button.c:133
+
uint16_t x1
Top Left X-Coordinate of Area.
Definition: touch.h:74
+
static void b_back_cb(void *button)
+
uint16_t bgcolor
The 16-bit background color of the button.
Definition: button.h:57
+
static int fontheight
+
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 HEX(h)
Definition: tft.h:60
+
uint16_t y2
Bottom Right Y-Coordinate of Area.
Definition: touch.h:77
+
static enum @0 state
+ +
void tft_clear(uint16_t color)
Definition: tft.c:45
+
static BUTTON_STRUCT b_back
+
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
+
#define WHITE
Definition: tft.h:53
+
static int num_files_ok
+
static FILE_LIST_ENTRY * files_ok
+
BUTTON_CALLBACK callback
Callback which is executed when the button is pressed.
Definition: button.h:58
+
uint8_t font
The number of the font to use.
Definition: button.h:60
+

Here is the call graph for this function:
@@ -333,6 +400,39 @@ Here is the call graph for this function:
+

Definition at line 310 of file screen_photomode_save.c.

+
311 {
+
312  gui_button_remove(&b_back); //Remove/Free the back button
+
313 
+
314  if (state == picking) { //The user left the screen in the "picking"-phase
+
315  touch_unregister_area(&a_area); //remove the touch area (for the list)
+
316  }
+
317 
+
318  if (state == picking || state == saving || state == done) { //the user left the screen after we created the linked list
+
319  //Iterate through the linked list and free all resources
+
320  FILE_LIST_ENTRY* current_entry = files_ok; //start with the list head
+
321 
+
322  while (current_entry != NULL) { //while we're not at the end
+
323  FILE_LIST_ENTRY* temp = current_entry->next; //save the next pointer because we free the current element on the next line
+
324  free((void*)(current_entry->filename)); //free filename
+
325  free(current_entry); //free element itself
+
326  current_entry = temp; //advance
+
327  }
+
328  }
+
329 }
+ + + + +
static TOUCH_AREA_STRUCT a_area
+
void touch_unregister_area(TOUCH_AREA_STRUCT *area)
Definition: touch.c:195
+
static enum @0 state
+
static BUTTON_STRUCT b_back
+
void gui_button_remove(BUTTON_STRUCT *button)
Definition: button.c:184
+
struct FILE_LIST_ENTRY_S * next
+ +
static FILE_LIST_ENTRY * files_ok
+

Here is the call graph for this function:
@@ -376,6 +476,42 @@ Here is the call graph for this function:
+

Definition at line 50 of file screen_photomode_save.c.

+
51 {
+
52 
+
53  int y = touch_get_last_point().y - liststart; //Calculate the y-Coordinate of the touch point relative to the start of the file-list
+
54  int elem = y / fontheight; //Calculate the file index
+
55 
+
56  if (elem < 0 | elem >= num_files_ok) {
+
57  return; //Check if the file index is valid (0,1,..,num_files_ok-1)
+
58  }
+
59 
+
60  //Search for the corresponding entry in the linked list
+
61  FILE_LIST_ENTRY* current_entry = files_ok; //Start walking through the list, starting by the head of the list
+
62 
+
63  for (int i = 0; i < elem; i++) { //Until we have reached the file (index)
+
64  current_entry = current_entry->next; //traverse to the next file
+
65  }
+
66 
+
67  picked_file = current_entry->filename; //save the picked filename. It will be used by the statemachine in the main loop
+
68  touch_unregister_area(&a_area); //unregister the touch area, we no longer need it. No more interrupts will be fired.
+
69  state = saving; //Change the state of the statemachine
+
70 }
+ +
uint16_t y
The Y-Coordinate of the point.
Definition: touch.h:88
+ +
static int fontheight
+ +
static TOUCH_AREA_STRUCT a_area
+
void touch_unregister_area(TOUCH_AREA_STRUCT *area)
Definition: touch.c:195
+
static enum @0 state
+
POINT_STRUCT touch_get_last_point()
Definition: touch.c:211
+
struct FILE_LIST_ENTRY_S * next
+
static int liststart
+
static int num_files_ok
+
static FILE_LIST_ENTRY * files_ok
+
static const char * picked_file
+

Here is the call graph for this function:
@@ -418,6 +554,243 @@ Here is the caller graph for this function:
+

Definition at line 135 of file screen_photomode_save.c.

+
136 {
+
137  switch (state) {
+
138  case init: { //Init State: The user just entered the screen
+
139  DIRECTORY_STRUCT* dir = filesystem_dir_open("."); //open root directory
+
140 
+
141  if (dir == NULL) { //error while opening root directory
+
142  tft_print_line(X_OFS, 5, BLACK, TRANSPARENT, 0, "Error accessing Filesystem");
+
143  state = error;
+
144  break;
+
145  }
+
146 
+
147  bool nomatch = true; //whether or not we have zero files which are suitable for saving
+
148 
+
149  for (int i = 0; i < dir->num_files; i++) { //walk through all files in the directory
+
150  FILE_STRUCT* file = &(dir->files[i]); //Pointer to the current file/subdirectory
+
151 
+
152  //Ignore directories, archives, hidden files, system files and files we cannot write to
+
153  if (file->fattrib & (F_SYS | F_HID | F_ARC | F_DIR | F_RDO)) {
+
154  continue;
+
155  }
+
156 
+
157  //ignore files which are not large enough
+
158  if (file->fsize < 189410) {
+
159  continue; //size taken from an example bitmap (318x198x24)
+
160  }
+
161 
+
162  nomatch = false; //at least one file matches
+
163  break;
+
164  }
+
165 
+
166  if (nomatch) { //not one file is suitable for writing
+
167  int y = 5; //y-Coordinate where to start writing the error text
+
168  int i = 0;
+
169 
+
170  while (nomatch_text[i] != NULL) { //for every line in the big error array
+
171  //Write the line's text and go to the next line
+ +
173  i++;
+
174  }
+
175 
+
176  state = error;
+
177  } else { //we have a least one suitable file
+
178  state = showlist;
+
179  }
+
180 
+
181  filesystem_dir_close(dir); //free directory struct
+
182  }
+
183  break;
+
184 
+
185  case showlist: { //Show List State: Where we load and present the suitable file's to the user in a list
+
186  DIRECTORY_STRUCT* dir2 = filesystem_dir_open("."); //Open the directory again
+
187 
+
188  if (dir2 == NULL) {
+
189  return; //Error on opening? This should never happen, since it's handled in the previous state
+
190  }
+
191 
+
192  int y = 5; //y-Coordinate where to start drawing/writing text/list-elements
+
193 
+
194  tft_print_line(X_OFS, y, BLACK, TRANSPARENT, 0, "Pick a file to save the image to");
+
195  y += fontheight + 5;
+
196 
+
197  tft_print_line(X_OFS, y, BLUE, TRANSPARENT, 0, "Name Modified Size");
+
198  y += fontheight;
+
199 
+
200  liststart = y; //store the y coordinate of the start of the list away (used in toucharea callback)
+
201  num_files_ok = 0; //we start with 0 matching files
+
202 
+
203  FILE_LIST_ENTRY* current_entry = NULL; //We start with an empty list
+
204 
+
205  for (int i = 0; i < dir2->num_files && num_files_ok < 10; i++) { //go through all the files of the directory, abort if we have 10 matches
+
206  FILE_STRUCT* file = &(dir2->files[i]);
+
207 
+
208  //Ignore directories, archives, hidden files, system files and files we cannot write to
+
209  if (file->fattrib & (F_SYS | F_HID | F_ARC | F_DIR | F_RDO)) {
+
210  continue;
+
211  }
+
212 
+
213  //ignore files which are not large enough
+
214  if (file->fsize < 189410) {
+
215  continue; //size taken from an example bitmap (318x198x24)
+
216  }
+
217 
+
218  //Print out filename, modified date,time and file size
+ +
220  TRANSPARENT, 0, "%-16s %02u.%02u.%02u %02u:%02u:%02u %u",
+
221  file->fname,
+
222  file->fdate.day,
+
223  file->fdate.month,
+
224  (file->fdate.year + 1980) % 100,
+
225  file->ftime.hour,
+
226  file->ftime.min,
+
227  file->ftime.sec * 2,
+
228  file->fsize);
+
229 
+
230  if (current_entry == NULL) { //The list is empty
+
231  current_entry = malloc(sizeof(FILE_LIST_ENTRY)); //create new entry
+
232  files_ok = current_entry; //assign it to the list head
+
233  } else { //there's a least one entry in the list
+
234  current_entry->next = malloc(sizeof(FILE_LIST_ENTRY)); //append entry to previous entry
+
235  current_entry = current_entry->next; //newly created entry is the current now.
+
236  }
+
237 
+
238  current_entry->next = NULL; //we're at the end of the list (for now)
+
239  current_entry->filename = malloc(strlen(file->fname) + 1); //allocate space for the filename + zero-termination
+
240  strcpy(current_entry->filename, file->fname); //copy filename (so that we can close the directory after scanning)
+
241 
+
242  //since we have found a suitable file we need to increment the position in the list
+
243  num_files_ok++;
+
244  y += fontheight;
+
245  }
+
246 
+
247  //Touch area for file-selection (in the list)
+
248  a_area.hookedActions = PEN_UP; //we're only interested in PEN_UP events
+
249  a_area.x1 = X_OFS; //Left border
+
250  a_area.y1 = liststart; //Start where the list started
+
251  a_area.x2 = 320 - X_OFS; //Right border
+
252  a_area.y2 = liststart + fontheight * num_files_ok; //stop at the end of the list
+
253  a_area.callback = touchCB; //execute our callback when PEN_UP occurs
+
254  touch_register_area(&a_area); //register the touch area and receive events from now on
+
255 
+
256  filesystem_dir_close(dir2); //we no longer need the directory struct, since we have our own linked list now
+
257 
+
258  state = picking;
+
259  }
+
260  break;
+
261 
+
262  case picking: //Picking State: Where we wait on the users file choice
+
263  pixy_service(); //Handle pending pixy events
+
264  //do nothing and wait on user to pick a file
+
265  break;
+
266 
+
267  case saving: { //Saving State: Where we save the image to the selected file
+
268  FILE_HANDLE* file = filesystem_file_open(picked_file); //try to open the selected file
+
269 
+
270  if (file == NULL) { //opening the file failed
+
271  tft_print_formatted(X_OFS, 190, BLUE, TRANSPARENT, 0, "Could not open %s", picked_file);
+
272  state = error;
+
273  break;
+
274  }
+
275 
+
276  filesystem_file_seek(file, 0); //seek to the start of the file (optional?)
+
277 
+
278  if (filesystem_file_write(file, bmpheader_data, 0x7A) != F_OK) { //Writing the header failed
+
279  tft_print_formatted(X_OFS, 190, BLUE, TRANSPARENT, 0, "Error while writing to %s", picked_file);
+
280  filesystem_file_close(file);
+
281  state = error;
+
282  break;
+
283  }
+
284 
+
285  if (pixy_save_full_frame(file) != 0) { //Writing the imagedata failed
+
286  tft_print_formatted(X_OFS, 190, BLUE, TRANSPARENT, 0, "Error while writing to %s", picked_file);
+
287  filesystem_file_close(file);
+
288  state = error;
+
289  break;
+
290  }
+
291 
+
292  //if we reach this point, we have written all data out successfully
+
293 
+
294  filesystem_file_close(file); //close/finalize the file
+
295  tft_print_formatted(X_OFS, 190, BLUE, TRANSPARENT, 0, "Image saved to %s", picked_file);
+
296  state = done;
+
297  }
+
298  break;
+
299 
+
300  case error: //Error State: Where we show an error message and leave the user no other choice than to click the backbutton
+
301  case done: //Done State: When saving the file was successful
+
302  pixy_service(); //Handle pending pixy events
+
303  //wait on user to click the back button
+
304  break;
+
305 
+
306  }
+
307 }
+
bool touch_register_area(TOUCH_AREA_STRUCT *area)
Definition: touch.c:181
+
static unsigned char bmpheader_data[0x7A]
+ +
FILE_STATUS filesystem_file_seek(FILE_HANDLE *handle, uint32_t offset)
Definition: filesystem.c:43
+
Receive an event when the pen goes up inside the region.
Definition: touch.h:55
+ +
unsigned sec
second/2 (0..29)
Definition: filesystem.h:55
+
uint16_t y1
Top Left Y-Coordinate of Area.
Definition: touch.h:75
+
void tft_print_formatted(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, const char *format,...)
Definition: tft.c:111
+
#define X_OFS
+
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
+
FILE_DATE_STRUCT fdate
Last modified date.
Definition: filesystem.h:63
+ +
unsigned day
day (1..31)
Definition: filesystem.h:46
+
uint8_t fattrib
File/Directory Attributes.
Definition: filesystem.h:65
+ +
uint16_t x1
Top Left X-Coordinate of Area.
Definition: touch.h:74
+
#define TRANSPARENT
Definition: tft.h:66
+ +
int pixy_save_full_frame(FILE_HANDLE *handle)
Definition: pixy_frame.c:65
+ +
static int fontheight
+ +
static TOUCH_AREA_STRUCT a_area
+
uint16_t y2
Bottom Right Y-Coordinate of Area.
Definition: touch.h:77
+
int pixy_service()
+
FILE_HANDLE * filesystem_file_open(const char *filename)
Definition: filesystem.c:33
+
static enum @0 state
+
void filesystem_file_close(FILE_HANDLE *handle)
Definition: filesystem.c:38
+ +
TOUCH_CALLBACK callback
Callback which is executed when an event occurred in this Area.
Definition: touch.h:78
+
File has the archive flag set (probably unused)
Definition: filesystem.h:37
+
char * fname
File/Directory name.
Definition: filesystem.h:66
+
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
+
File is a system file.
Definition: filesystem.h:35
+
unsigned year
year from 1980 (0..127)
Definition: filesystem.h:44
+
uint16_t num_files
Number of files/directories in this directory.
Definition: filesystem.h:74
+
unsigned month
month (1..12)
Definition: filesystem.h:45
+
FILE_STATUS filesystem_file_write(FILE_HANDLE *handle, uint8_t *buf, uint32_t size)
Definition: filesystem.c:53
+
unsigned min
minute (0..59
Definition: filesystem.h:54
+ +
File is hidden.
Definition: filesystem.h:34
+
struct FILE_LIST_ENTRY_S * next
+
unsigned hour
hour (0..23)
Definition: filesystem.h:53
+
TOUCH_ACTION hookedActions
Actions to listen to.
Definition: touch.h:73
+
Everything ok.
Definition: filesystem.h:91
+
FILE_STRUCT * files
An array with num_files FILE_STRUCT entries.
Definition: filesystem.h:75
+ +
DIRECTORY_STRUCT * filesystem_dir_open(const char *path)
Definition: filesystem.c:23
+
#define BLUE
Definition: tft.h:52
+
static int liststart
+
It's a directory and not a file.
Definition: filesystem.h:36
+
static int num_files_ok
+ +
static FILE_LIST_ENTRY * files_ok
+
File is readonly. You cannot write to it.
Definition: filesystem.h:33
+
static void touchCB(void *touchArea, TOUCH_ACTION triggeredAction)
+
static const char * picked_file
+
static const char * nomatch_text[]
+
void filesystem_dir_close(DIRECTORY_STRUCT *dir)
Definition: filesystem.c:28
+
FILE_TIME_STRUCT ftime
Last modified time.
Definition: filesystem.h:64
+
#define BLACK
Definition: tft.h:54
+
uint32_t fsize
File size in bytes. 0 for directories.
Definition: filesystem.h:62
+

Here is the call graph for this function:
@@ -448,6 +821,8 @@ Here is the call graph for this function:
+

Definition at line 27 of file screen_photomode_save.c.

+
@@ -468,6 +843,8 @@ Here is the call graph for this function:
+

Definition at line 26 of file screen_photomode_save.c.

+
@@ -488,19 +865,21 @@ Here is the call graph for this function:
Initial value:
= {
-
0x42, 0x4d, 0xe2, 0xe3, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7a, 0x00,
-
0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x3e, 0x01, 0x00, 0x00, 0xc6, 0x00,
-
0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0xe3,
-
0x02, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00,
-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x47, 0x52, 0x73, 0x00, 0x00,
-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-
0x00, 0x00
+
0x42, 0x4d, 0xe2, 0xe3, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7a, 0x00,
+
0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x3e, 0x01, 0x00, 0x00, 0xc6, 0x00,
+
0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0xe3,
+
0x02, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00,
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x47, 0x52, 0x73, 0x00, 0x00,
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
0x00, 0x00
}
+

Definition at line 93 of file screen_photomode_save.c.

+
@@ -521,6 +900,8 @@ Here is the call graph for this function:
+

Definition at line 47 of file screen_photomode_save.c.

+
@@ -541,6 +922,8 @@ Here is the call graph for this function:
+

Definition at line 37 of file screen_photomode_save.c.

+
@@ -561,6 +944,8 @@ Here is the call graph for this function:
+

Definition at line 38 of file screen_photomode_save.c.

+
@@ -596,6 +981,8 @@ Here is the call graph for this function:
NULL
}
+

Definition at line 73 of file screen_photomode_save.c.

+ @@ -616,6 +1003,8 @@ Here is the call graph for this function:
+

Definition at line 35 of file screen_photomode_save.c.

+
@@ -636,6 +1025,8 @@ Here is the call graph for this function:
+

Definition at line 39 of file screen_photomode_save.c.

+
@@ -660,10 +1051,12 @@ Here is the call graph for this function:
leave,
update
}
-
static void update(void *screen)
Definition: screen_photomode_save.c:114
-
static void enter(void *screen)
Definition: screen_photomode_save.c:88
-
static void leave(void *screen)
Definition: screen_photomode_save.c:273
+
static void update(void *screen)
+
static void enter(void *screen)
+
static void leave(void *screen)
+

Definition at line 332 of file screen_photomode_save.c.

+ @@ -681,7 +1074,7 @@ Here is the call graph for this function: diff --git a/screen__photomode__save_8c_source.html b/screen__photomode__save_8c_source.html new file mode 100644 index 0000000..ec583c1 --- /dev/null +++ b/screen__photomode__save_8c_source.html @@ -0,0 +1,540 @@ + + + + + + +discoverpixy: common/app/screen_photomode_save.c Source File + + + + + + + + + + +
+
+ + + + + + +
+
discoverpixy +
+
+
+ + + + + + +
+
+ + +
+ +
+ + +
+
+
+
screen_photomode_save.c
+
+
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/app/screen_photomode_save.c
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-05-16 timolang@gmail.com 62006e0 Documented pixy_helper and implemented/finished photo-mode screens! Snap some shots!
+
11 * 2015-06-07 timolang@gmail.com c87220d Renamed pixy_helper to pixy_frame. Updated docu of appliaction. added doxygen comments to pixy_{frame,control}.h
+
12 *
+
13 **************************************************************************************************************************************/
+
14 
+
15 #include "screen_photomode_save.h"
+
16 #include "filesystem.h"
+
17 #include "button.h"
+
18 #include "tft.h"
+
19 #include "touch.h"
+
20 #include "pixy.h"
+
21 #include "pixy_frame.h"
+
22 #include <stdlib.h>
+
23 #include <string.h>
+
24 
+
25 
+
26 static BUTTON_STRUCT b_back; //Button to navigate back
+
27 static TOUCH_AREA_STRUCT a_area; //Touch area to select the save-file
+
28 
+
29 //Callback for when the user presses the "back" button
+
30 static void b_back_cb(void* button)
+
31 {
+ +
33 }
+
34 
+
35 static int num_files_ok; //number of files into which we can write the image (size, flags ok)
+
36 static enum {init, error, showlist, picking, saving, done} state; //Current state of the screen state machine
+
37 static int fontheight; //The space between one line of text to the next
+
38 static int liststart; //The y-Coordinate of the Start of the File-List
+
39 static const char* picked_file; //The filename picked by the user, to save the image to
+
40 
+
41 //Linked list structure to save all files which are suitable for saving.
+
42 typedef struct FILE_LIST_ENTRY_S {
+
43  char* filename; //Name of the file
+
44  struct FILE_LIST_ENTRY_S* next; //Pointer to the next entry in the list or NULL
+ +
46 
+
47 static FILE_LIST_ENTRY* files_ok; //Pointer to the head of the list
+
48 
+
49 //Callback for when the user selects a file to save the image into
+
50 static void touchCB(void* touchArea, TOUCH_ACTION triggeredAction)
+
51 {
+
52 
+
53  int y = touch_get_last_point().y - liststart; //Calculate the y-Coordinate of the touch point relative to the start of the file-list
+
54  int elem = y / fontheight; //Calculate the file index
+
55 
+
56  if (elem < 0 | elem >= num_files_ok) {
+
57  return; //Check if the file index is valid (0,1,..,num_files_ok-1)
+
58  }
+
59 
+
60  //Search for the corresponding entry in the linked list
+
61  FILE_LIST_ENTRY* current_entry = files_ok; //Start walking through the list, starting by the head of the list
+
62 
+
63  for (int i = 0; i < elem; i++) { //Until we have reached the file (index)
+
64  current_entry = current_entry->next; //traverse to the next file
+
65  }
+
66 
+
67  picked_file = current_entry->filename; //save the picked filename. It will be used by the statemachine in the main loop
+
68  touch_unregister_area(&a_area); //unregister the touch area, we no longer need it. No more interrupts will be fired.
+
69  state = saving; //Change the state of the statemachine
+
70 }
+
71 
+
72 //Text-Lines to show if we have no matching files (num_files_ok==0)
+
73 static const char* nomatch_text [] = {
+
74  "Due to limitations of the filesystem",
+
75  "implementation you can only write to",
+
76  "existing files.",
+
77  "",
+
78  "The files need to have a .bmp",
+
79  "extension and must be at least",
+
80  "189410 bytes (185kb) large.",
+
81  "Unfortunately there were no such",
+
82  "files found in the root directory.",
+
83  "",
+
84  "Please create some files and come",
+
85  "back again.",
+
86  NULL
+
87 };
+
88 
+
89 
+
90 //Bitmap header for a 318x198x24bit windows bitmap. data starts at 0x7A (= after this header)
+
91 //This header has been taken from a white bitmap saved with gimp.
+
92 //Wikipedia has a pretty good description on the header: http://de.wikipedia.org/wiki/Windows_Bitmap
+
93 static unsigned char bmpheader_data[0x7A] = {
+
94  0x42, 0x4d, 0xe2, 0xe3, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7a, 0x00,
+
95  0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x3e, 0x01, 0x00, 0x00, 0xc6, 0x00,
+
96  0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0xe3,
+
97  0x02, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00,
+
98  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x47, 0x52, 0x73, 0x00, 0x00,
+
99  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
100  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
101  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
102  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
+
103  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
104  0x00, 0x00
+
105 };
+
106 
+
107 //Callback for when the screen is entered/loaded
+
108 static void enter(void* screen)
+
109 {
+
110  tft_clear(WHITE);
+
111 
+
112 
+
113 #define X_OFS 5
+
114 
+
115  //Back button
+
116  b_back.base.x1 = X_OFS; //Start X of Button
+
117  b_back.base.y1 = 210; //Start Y of Button
+
118  b_back.base.x2 = AUTO; //Auto Calculate X2 with String Width
+
119  b_back.base.y2 = AUTO; //Auto Calculate Y2 with String Height
+
120  b_back.txtcolor = WHITE; //Set foreground color
+
121  b_back.bgcolor = HEX(0xAE1010); //Set background color (Don't take 255 or 0 on at least one channel, to make shadows possible)
+
122  b_back.font = 0; //Select Font
+
123  b_back.text = "Back"; //Set Text (For formatted strings take sprintf)
+
124  b_back.callback = b_back_cb; //Call b_back_cb as Callback
+
125  gui_button_add(&b_back); //Register Button (and run the callback from now on)
+
126 
+
127  state = init; //Start with the init state
+
128  fontheight = tft_font_height(0) + 2; //Save the height of the used font, for fast access
+
129  files_ok = NULL; //initialize the linked list with 0 elements
+
130  num_files_ok = 0; //we have zero! elements
+
131 }
+
132 
+
133 //Callback for when the screen should be updated
+
134 //This is the main loop of the screen. This method will be called repeatedly
+
135 static void update(void* screen)
+
136 {
+
137  switch (state) {
+
138  case init: { //Init State: The user just entered the screen
+
139  DIRECTORY_STRUCT* dir = filesystem_dir_open("."); //open root directory
+
140 
+
141  if (dir == NULL) { //error while opening root directory
+
142  tft_print_line(X_OFS, 5, BLACK, TRANSPARENT, 0, "Error accessing Filesystem");
+
143  state = error;
+
144  break;
+
145  }
+
146 
+
147  bool nomatch = true; //whether or not we have zero files which are suitable for saving
+
148 
+
149  for (int i = 0; i < dir->num_files; i++) { //walk through all files in the directory
+
150  FILE_STRUCT* file = &(dir->files[i]); //Pointer to the current file/subdirectory
+
151 
+
152  //Ignore directories, archives, hidden files, system files and files we cannot write to
+
153  if (file->fattrib & (F_SYS | F_HID | F_ARC | F_DIR | F_RDO)) {
+
154  continue;
+
155  }
+
156 
+
157  //ignore files which are not large enough
+
158  if (file->fsize < 189410) {
+
159  continue; //size taken from an example bitmap (318x198x24)
+
160  }
+
161 
+
162  nomatch = false; //at least one file matches
+
163  break;
+
164  }
+
165 
+
166  if (nomatch) { //not one file is suitable for writing
+
167  int y = 5; //y-Coordinate where to start writing the error text
+
168  int i = 0;
+
169 
+
170  while (nomatch_text[i] != NULL) { //for every line in the big error array
+
171  //Write the line's text and go to the next line
+ +
173  i++;
+
174  }
+
175 
+
176  state = error;
+
177  } else { //we have a least one suitable file
+
178  state = showlist;
+
179  }
+
180 
+
181  filesystem_dir_close(dir); //free directory struct
+
182  }
+
183  break;
+
184 
+
185  case showlist: { //Show List State: Where we load and present the suitable file's to the user in a list
+
186  DIRECTORY_STRUCT* dir2 = filesystem_dir_open("."); //Open the directory again
+
187 
+
188  if (dir2 == NULL) {
+
189  return; //Error on opening? This should never happen, since it's handled in the previous state
+
190  }
+
191 
+
192  int y = 5; //y-Coordinate where to start drawing/writing text/list-elements
+
193 
+
194  tft_print_line(X_OFS, y, BLACK, TRANSPARENT, 0, "Pick a file to save the image to");
+
195  y += fontheight + 5;
+
196 
+
197  tft_print_line(X_OFS, y, BLUE, TRANSPARENT, 0, "Name Modified Size");
+
198  y += fontheight;
+
199 
+
200  liststart = y; //store the y coordinate of the start of the list away (used in toucharea callback)
+
201  num_files_ok = 0; //we start with 0 matching files
+
202 
+
203  FILE_LIST_ENTRY* current_entry = NULL; //We start with an empty list
+
204 
+
205  for (int i = 0; i < dir2->num_files && num_files_ok < 10; i++) { //go through all the files of the directory, abort if we have 10 matches
+
206  FILE_STRUCT* file = &(dir2->files[i]);
+
207 
+
208  //Ignore directories, archives, hidden files, system files and files we cannot write to
+
209  if (file->fattrib & (F_SYS | F_HID | F_ARC | F_DIR | F_RDO)) {
+
210  continue;
+
211  }
+
212 
+
213  //ignore files which are not large enough
+
214  if (file->fsize < 189410) {
+
215  continue; //size taken from an example bitmap (318x198x24)
+
216  }
+
217 
+
218  //Print out filename, modified date,time and file size
+ +
220  TRANSPARENT, 0, "%-16s %02u.%02u.%02u %02u:%02u:%02u %u",
+
221  file->fname,
+
222  file->fdate.day,
+
223  file->fdate.month,
+
224  (file->fdate.year + 1980) % 100,
+
225  file->ftime.hour,
+
226  file->ftime.min,
+
227  file->ftime.sec * 2,
+
228  file->fsize);
+
229 
+
230  if (current_entry == NULL) { //The list is empty
+
231  current_entry = malloc(sizeof(FILE_LIST_ENTRY)); //create new entry
+
232  files_ok = current_entry; //assign it to the list head
+
233  } else { //there's a least one entry in the list
+
234  current_entry->next = malloc(sizeof(FILE_LIST_ENTRY)); //append entry to previous entry
+
235  current_entry = current_entry->next; //newly created entry is the current now.
+
236  }
+
237 
+
238  current_entry->next = NULL; //we're at the end of the list (for now)
+
239  current_entry->filename = malloc(strlen(file->fname) + 1); //allocate space for the filename + zero-termination
+
240  strcpy(current_entry->filename, file->fname); //copy filename (so that we can close the directory after scanning)
+
241 
+
242  //since we have found a suitable file we need to increment the position in the list
+
243  num_files_ok++;
+
244  y += fontheight;
+
245  }
+
246 
+
247  //Touch area for file-selection (in the list)
+
248  a_area.hookedActions = PEN_UP; //we're only interested in PEN_UP events
+
249  a_area.x1 = X_OFS; //Left border
+
250  a_area.y1 = liststart; //Start where the list started
+
251  a_area.x2 = 320 - X_OFS; //Right border
+
252  a_area.y2 = liststart + fontheight * num_files_ok; //stop at the end of the list
+
253  a_area.callback = touchCB; //execute our callback when PEN_UP occurs
+
254  touch_register_area(&a_area); //register the touch area and receive events from now on
+
255 
+
256  filesystem_dir_close(dir2); //we no longer need the directory struct, since we have our own linked list now
+
257 
+
258  state = picking;
+
259  }
+
260  break;
+
261 
+
262  case picking: //Picking State: Where we wait on the users file choice
+
263  pixy_service(); //Handle pending pixy events
+
264  //do nothing and wait on user to pick a file
+
265  break;
+
266 
+
267  case saving: { //Saving State: Where we save the image to the selected file
+
268  FILE_HANDLE* file = filesystem_file_open(picked_file); //try to open the selected file
+
269 
+
270  if (file == NULL) { //opening the file failed
+
271  tft_print_formatted(X_OFS, 190, BLUE, TRANSPARENT, 0, "Could not open %s", picked_file);
+
272  state = error;
+
273  break;
+
274  }
+
275 
+
276  filesystem_file_seek(file, 0); //seek to the start of the file (optional?)
+
277 
+
278  if (filesystem_file_write(file, bmpheader_data, 0x7A) != F_OK) { //Writing the header failed
+
279  tft_print_formatted(X_OFS, 190, BLUE, TRANSPARENT, 0, "Error while writing to %s", picked_file);
+
280  filesystem_file_close(file);
+
281  state = error;
+
282  break;
+
283  }
+
284 
+
285  if (pixy_save_full_frame(file) != 0) { //Writing the imagedata failed
+
286  tft_print_formatted(X_OFS, 190, BLUE, TRANSPARENT, 0, "Error while writing to %s", picked_file);
+
287  filesystem_file_close(file);
+
288  state = error;
+
289  break;
+
290  }
+
291 
+
292  //if we reach this point, we have written all data out successfully
+
293 
+
294  filesystem_file_close(file); //close/finalize the file
+
295  tft_print_formatted(X_OFS, 190, BLUE, TRANSPARENT, 0, "Image saved to %s", picked_file);
+
296  state = done;
+
297  }
+
298  break;
+
299 
+
300  case error: //Error State: Where we show an error message and leave the user no other choice than to click the backbutton
+
301  case done: //Done State: When saving the file was successful
+
302  pixy_service(); //Handle pending pixy events
+
303  //wait on user to click the back button
+
304  break;
+
305 
+
306  }
+
307 }
+
308 
+
309 //Callback for when the screen is left/unloaded
+
310 static void leave(void* screen)
+
311 {
+
312  gui_button_remove(&b_back); //Remove/Free the back button
+
313 
+
314  if (state == picking) { //The user left the screen in the "picking"-phase
+
315  touch_unregister_area(&a_area); //remove the touch area (for the list)
+
316  }
+
317 
+
318  if (state == picking || state == saving || state == done) { //the user left the screen after we created the linked list
+
319  //Iterate through the linked list and free all resources
+
320  FILE_LIST_ENTRY* current_entry = files_ok; //start with the list head
+
321 
+
322  while (current_entry != NULL) { //while we're not at the end
+
323  FILE_LIST_ENTRY* temp = current_entry->next; //save the next pointer because we free the current element on the next line
+
324  free((void*)(current_entry->filename)); //free filename
+
325  free(current_entry); //free element itself
+
326  current_entry = temp; //advance
+
327  }
+
328  }
+
329 }
+
330 
+
331 //Declare screen callbacks
+ +
333  enter,
+
334  leave,
+
335  update
+
336 };
+
337 
+ +
339 {
+
340  return &screen;
+
341 }
+
TOUCH_ACTION
Definition: touch.h:52
+
uint8_t tft_font_height(uint8_t fontnum)
Definition: tft.c:87
+
bool touch_register_area(TOUCH_AREA_STRUCT *area)
Definition: touch.c:181
+
static unsigned char bmpheader_data[0x7A]
+
const char * text
The label of the button.
Definition: button.h:61
+
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
+
FILE_STATUS filesystem_file_seek(FILE_HANDLE *handle, uint32_t offset)
Definition: filesystem.c:43
+
Receive an event when the pen goes up inside the region.
Definition: touch.h:55
+ +
unsigned sec
second/2 (0..29)
Definition: filesystem.h:55
+
SCREEN_STRUCT * get_screen_photomodesave()
+
uint16_t y1
Top Left Y-Coordinate of Area.
Definition: touch.h:75
+
void tft_print_formatted(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, const char *format,...)
Definition: tft.c:111
+
uint16_t y
The Y-Coordinate of the point.
Definition: touch.h:88
+
#define X_OFS
+ +
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
+
FILE_DATE_STRUCT fdate
Last modified date.
Definition: filesystem.h:63
+ +
unsigned day
day (1..31)
Definition: filesystem.h:46
+
uint8_t fattrib
File/Directory Attributes.
Definition: filesystem.h:65
+ +
uint16_t x1
Top Left X-Coordinate of Area.
Definition: touch.h:74
+
static void b_back_cb(void *button)
+ +
#define TRANSPARENT
Definition: tft.h:66
+ +
int pixy_save_full_frame(FILE_HANDLE *handle)
Definition: pixy_frame.c:65
+
uint16_t bgcolor
The 16-bit background color of the button.
Definition: button.h:57
+ +
static int fontheight
+ +
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
+
static TOUCH_AREA_STRUCT a_area
+
void touch_unregister_area(TOUCH_AREA_STRUCT *area)
Definition: touch.c:195
+
#define HEX(h)
Definition: tft.h:60
+ +
uint16_t y2
Bottom Right Y-Coordinate of Area.
Definition: touch.h:77
+
struct FILE_LIST_ENTRY_S FILE_LIST_ENTRY
+
int pixy_service()
+ +
FILE_HANDLE * filesystem_file_open(const char *filename)
Definition: filesystem.c:33
+
static enum @0 state
+
void filesystem_file_close(FILE_HANDLE *handle)
Definition: filesystem.c:38
+ + +
TOUCH_CALLBACK callback
Callback which is executed when an event occurred in this Area.
Definition: touch.h:78
+
File has the archive flag set (probably unused)
Definition: filesystem.h:37
+ +
char * fname
File/Directory name.
Definition: filesystem.h:66
+
void tft_clear(uint16_t color)
Definition: tft.c:45
+
static BUTTON_STRUCT b_back
+
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
+ + +
File is a system file.
Definition: filesystem.h:35
+
void gui_button_remove(BUTTON_STRUCT *button)
Definition: button.c:184
+
unsigned year
year from 1980 (0..127)
Definition: filesystem.h:44
+
uint16_t num_files
Number of files/directories in this directory.
Definition: filesystem.h:74
+
unsigned month
month (1..12)
Definition: filesystem.h:45
+
FILE_STATUS filesystem_file_write(FILE_HANDLE *handle, uint8_t *buf, uint32_t size)
Definition: filesystem.c:53
+ +
#define WHITE
Definition: tft.h:53
+
unsigned min
minute (0..59
Definition: filesystem.h:54
+
POINT_STRUCT touch_get_last_point()
Definition: touch.c:211
+ +
File is hidden.
Definition: filesystem.h:34
+ +
static SCREEN_STRUCT screen
+
struct FILE_LIST_ENTRY_S * next
+
unsigned hour
hour (0..23)
Definition: filesystem.h:53
+
TOUCH_ACTION hookedActions
Actions to listen to.
Definition: touch.h:73
+
static void update(void *screen)
+
Everything ok.
Definition: filesystem.h:91
+
FILE_STRUCT * files
An array with num_files FILE_STRUCT entries.
Definition: filesystem.h:75
+ +
DIRECTORY_STRUCT * filesystem_dir_open(const char *path)
Definition: filesystem.c:23
+
static void enter(void *screen)
+
#define BLUE
Definition: tft.h:52
+
static int liststart
+
It's a directory and not a file.
Definition: filesystem.h:36
+
static int num_files_ok
+ +
static FILE_LIST_ENTRY * files_ok
+
File is readonly. You cannot write to it.
Definition: filesystem.h:33
+
static void leave(void *screen)
+
BUTTON_CALLBACK callback
Callback which is executed when the button is pressed.
Definition: button.h:58
+
static void touchCB(void *touchArea, TOUCH_ACTION triggeredAction)
+
bool gui_screen_back()
Definition: screen.c:85
+
static const char * picked_file
+
uint8_t font
The number of the font to use.
Definition: button.h:60
+
static const char * nomatch_text[]
+
void filesystem_dir_close(DIRECTORY_STRUCT *dir)
Definition: filesystem.c:28
+
FILE_TIME_STRUCT ftime
Last modified time.
Definition: filesystem.h:64
+
#define BLACK
Definition: tft.h:54
+
uint32_t fsize
File size in bytes. 0 for directories.
Definition: filesystem.h:62
+
+ + + + diff --git a/screen__photomode__save_8h.html b/screen__photomode__save_8h.html index 3ae31ed..4d28e26 100644 --- a/screen__photomode__save_8h.html +++ b/screen__photomode__save_8h.html @@ -117,7 +117,7 @@ Functions diff --git a/screen__photomode__save_8h_source.html b/screen__photomode__save_8h_source.html index cd8fb2c..529868b 100644 --- a/screen__photomode__save_8h_source.html +++ b/screen__photomode__save_8h_source.html @@ -89,20 +89,32 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
screen_photomode_save.h
-Go to the documentation of this file.
1 #include "screen.h"
-
2 
-
7 
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/app/screen_photomode_save.h
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-05-16 timolang@gmail.com 62006e0 Documented pixy_helper and implemented/finished photo-mode screens! Snap some shots!
+
11 *
+
12 **************************************************************************************************************************************/
13 
- +
14 #include "screen.h"
+
15 
20 
-
23 
-
SCREEN_STRUCT * get_screen_photomodesave()
Definition: screen_photomode_save.c:299
+
26 
+ +
33 
+
SCREEN_STRUCT * get_screen_photomodesave()
-
Definition: screen.h:34
+
diff --git a/screen__pixytest_8c.html b/screen__pixytest_8c.html index 5ceb9d2..916e28f 100644 --- a/screen__pixytest_8c.html +++ b/screen__pixytest_8c.html @@ -109,7 +109,9 @@ Include dependency graph for screen_pixytest.c:
- + +

Go to the source code of this file.

+
@@ -294,6 +296,15 @@ Variables

Macros

#define SERVO_BUTTON_Y   10
+

Definition at line 30 of file screen_pixytest.c.

+
30 {detecting, idle, update_servos, update_ledcolor, update_ledcurrent} state; //Current state of the screen state machine
+ + + +
static enum @1 state
+ + +

Function Documentation

@@ -319,6 +330,12 @@ Variables
+

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:
@@ -361,6 +378,18 @@ Here is the caller graph for this function:
+

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:
@@ -394,6 +423,18 @@ Here is the caller graph for this function:
+

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:
@@ -427,6 +468,18 @@ Here is the caller graph for this function:
+

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:
@@ -460,6 +513,18 @@ Here is the caller graph for this function:
+

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:
@@ -493,6 +558,18 @@ Here is the caller graph for this function:
+

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:
@@ -526,6 +603,20 @@ Here is the caller graph for this function:
+

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:
@@ -559,6 +650,20 @@ Here is the caller graph for this function:
+

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:
@@ -592,6 +697,20 @@ Here is the caller graph for this function:
+

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:
@@ -625,6 +744,20 @@ Here is the caller graph for this function:
+

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:
@@ -658,6 +791,20 @@ Here is the caller graph for this function:
+

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:
@@ -691,6 +838,219 @@ Here is the caller graph for this function:
+

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:
@@ -724,6 +1084,37 @@ Here is the call graph for this function:
+

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:
@@ -767,6 +1158,18 @@ Here is the call graph for this function:
+

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:
@@ -800,6 +1203,65 @@ Here is the caller graph for this function:
+

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:
@@ -830,6 +1292,8 @@ Here is the call graph for this function:
+

Definition at line 32 of file screen_pixytest.c.

+
@@ -850,6 +1314,8 @@ Here is the call graph for this function:
+

Definition at line 46 of file screen_pixytest.c.

+
@@ -870,6 +1336,8 @@ Here is the call graph for this function:
+

Definition at line 45 of file screen_pixytest.c.

+
@@ -890,6 +1358,8 @@ Here is the call graph for this function:
+

Definition at line 42 of file screen_pixytest.c.

+
@@ -910,6 +1380,8 @@ Here is the call graph for this function:
+

Definition at line 44 of file screen_pixytest.c.

+
@@ -930,6 +1402,8 @@ Here is the call graph for this function:
+

Definition at line 43 of file screen_pixytest.c.

+
@@ -950,6 +1424,8 @@ Here is the call graph for this function:
+

Definition at line 37 of file screen_pixytest.c.

+
@@ -970,6 +1446,8 @@ Here is the call graph for this function:
+

Definition at line 38 of file screen_pixytest.c.

+
@@ -990,6 +1468,8 @@ Here is the call graph for this function:
+

Definition at line 34 of file screen_pixytest.c.

+
@@ -1010,6 +1490,8 @@ Here is the call graph for this function:
+

Definition at line 35 of file screen_pixytest.c.

+
@@ -1030,6 +1512,8 @@ Here is the call graph for this function:
+

Definition at line 36 of file screen_pixytest.c.

+
@@ -1050,6 +1534,8 @@ Here is the call graph for this function:
+

Definition at line 47 of file screen_pixytest.c.

+
@@ -1070,6 +1556,8 @@ Here is the call graph for this function:
+

Definition at line 49 of file screen_pixytest.c.

+
@@ -1090,6 +1578,8 @@ Here is the call graph for this function:
+

Definition at line 50 of file screen_pixytest.c.

+
@@ -1114,10 +1604,12 @@ Here is the call graph for this function:
leave,
update
}
-
static void leave(void *screen)
Definition: screen_pixytest.c:274
-
static void update(void *screen)
Definition: screen_pixytest.c:291
-
static void enter(void *screen)
Definition: screen_pixytest.c:119
+
static void leave(void *screen)
+
static void update(void *screen)
+
static void enter(void *screen)
+

Definition at line 367 of file screen_pixytest.c.

+ @@ -1138,6 +1630,8 @@ Here is the call graph for this function:
+

Definition at line 39 of file screen_pixytest.c.

+
@@ -1158,6 +1652,8 @@ Here is the call graph for this function:
+

Definition at line 40 of file screen_pixytest.c.

+
@@ -1175,7 +1671,7 @@ Here is the call graph for this function: diff --git a/screen__pixytest_8c_source.html b/screen__pixytest_8c_source.html new file mode 100644 index 0000000..52f9770 --- /dev/null +++ b/screen__pixytest_8c_source.html @@ -0,0 +1,569 @@ + + + + + + +discoverpixy: common/app/screen_pixytest.c Source File + + + + + + + + + + +
+
+ + + + + + +
+
discoverpixy +
+
+
+ + + + + + +
+
+ + +
+ +
+ + +
+
+
+
screen_pixytest.c
+
+
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/app/screen_pixytest.c
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-04-27 timolang@gmail.com cf72baa Introduced a Screen (sub) module and divided app into multiple screens.
+
11 * 2015-05-02 timolang@gmail.com 3281616 Added some more touch functions. Improved pixy test. Drag the Image around!
+
12 * 2015-05-09 timolang@gmail.com 0b5173e Added reference tracking.
+
13 * 2015-05-15 timolang@gmail.com 27c09ba Redesigned main menu. Moved stuff from pixytest to a new helper file and to the new "photo mode"-screen.
+
14 * 2015-05-25 timolang@gmail.com 6a61769 Reimplemented pixytest screen. Added a lot of Test-Buttons.
+
15 * 2015-06-01 aaron@duckpond.ch caa7b5c Added IRQ for user button, fixed some touchproblems.
+
16 * 2015-06-03 timolang@gmail.com 74aa186 Made pixy_test screen working again. Had to disable pixy_service. Recalibrated initial touch values.
+
17 * 2015-06-07 timolang@gmail.com c87220d Renamed pixy_helper to pixy_frame. Updated docu of appliaction. added doxygen comments to pixy_{frame,control}.h
+
18 *
+
19 **************************************************************************************************************************************/
+
20 
+
21 #include "screen_pixytest.h"
+
22 #include "button.h"
+
23 #include "numupdown.h"
+
24 #include "tft.h"
+
25 #include "touch.h"
+
26 #include "pixy.h"
+
27 #include "system.h"
+
28 #include "pixy_frame.h"
+
29 
+
30 static volatile enum {detecting, idle, update_servos, update_ledcolor, update_ledcurrent} state; //Current state of the screen state machine
+
31 
+ +
33 
+ + + + + +
39 static uint16_t servo_x;
+
40 static uint16_t servo_y;
+
41 
+ + + + + +
47 static uint32_t led_color;
+
48 
+
49 static uint32_t led_maxcurrent;
+ +
51 
+
52 
+
53 static void b_back_cb(void* button)
+
54 {
+ +
56 }
+
57 
+
58 static void b_servos_center_cb(void* button)
+
59 {
+
60  if (state == idle) {
+
61  servo_x = 500;
+
62  servo_y = 500;
+ +
64  }
+
65 }
+
66 
+
67 static void b_servos_topleft_cb(void* button)
+
68 {
+
69  if (state == idle) {
+
70  servo_x = 0;
+
71  servo_y = 0;
+ +
73  }
+
74 }
+
75 
+
76 static void b_servos_topright_cb(void* button)
+
77 {
+
78  if (state == idle) {
+
79  servo_x = 1000;
+
80  servo_y = 0;
+ +
82  }
+
83 }
+
84 
+
85 static void b_servos_bottomleft_cb(void* button)
+
86 {
+
87  if (state == idle) {
+
88  servo_x = 0;
+
89  servo_y = 1000;
+ +
91  }
+
92 }
+
93 
+
94 static void b_servos_bottomright_cb(void* button)
+
95 {
+
96  if (state == idle) {
+
97  servo_x = 1000;
+
98  servo_y = 1000;
+ +
100  }
+
101 }
+
102 
+
103 static void b_led_off_cb(void* button)
+
104 {
+
105  if (state == idle) {
+
106  led_color = 0x000000;
+ +
108  }
+
109 }
+
110 
+
111 static void b_led_white_cb(void* button)
+
112 {
+
113  if (state == idle) {
+
114  led_color = 0xFFFFFF;
+ +
116  }
+
117 }
+
118 
+
119 static void b_led_red_cb(void* button)
+
120 {
+
121  if (state == idle) {
+
122  led_color = 0xFF0000;
+ +
124  }
+
125 }
+
126 
+
127 static void b_led_green_cb(void* button)
+
128 {
+
129  if (state == idle) {
+
130  led_color = 0x00FF00;
+ +
132  }
+
133 }
+
134 
+
135 static void b_led_blue_cb(void* button)
+
136 {
+
137  if (state == idle) {
+
138  led_color = 0x0000FF;
+ +
140  }
+
141 }
+
142 
+
143 static void n_led_powerlimit_cb(void* numupdown, int16_t value)
+
144 {
+
145  if (state == idle) {
+
146  led_maxcurrent = value;
+ +
148  }
+
149 }
+
150 
+
151 static void enter(void* screen)
+
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;
+
174  b_servos_center.base.y1 = SERVO_BUTTON_Y - 3;
+
175  b_servos_center.base.x2 = AUTO;
+
176  b_servos_center.base.y2 = AUTO;
+
177  b_servos_center.txtcolor = WHITE;
+
178  b_servos_center.bgcolor = HEX(0xAE1010);
+
179  b_servos_center.font = 0;
+
180  b_servos_center.text = "Center";
+
181  b_servos_center.callback = b_servos_center_cb;
+
182  gui_button_add(&b_servos_center);
+
183 
+
184  b_servos_topleft.base.x1 = b_servos_center.base.x2 + SERVO_BUTTON_SPACING;
+
185  b_servos_topleft.base.y1 = SERVO_BUTTON_Y - 3;
+
186  b_servos_topleft.base.x2 = AUTO;
+
187  b_servos_topleft.base.y2 = AUTO;
+
188  b_servos_topleft.txtcolor = WHITE;
+
189  b_servos_topleft.bgcolor = HEX(0xAE1010);
+
190  b_servos_topleft.font = 0;
+
191  b_servos_topleft.text = "ToLe";
+
192  b_servos_topleft.callback = b_servos_topleft_cb;
+
193  gui_button_add(&b_servos_topleft);
+
194 
+
195  b_servos_topright.base.x1 = b_servos_topleft.base.x2 + SERVO_BUTTON_SPACING;
+
196  b_servos_topright.base.y1 = SERVO_BUTTON_Y - 3;
+
197  b_servos_topright.base.x2 = AUTO;
+
198  b_servos_topright.base.y2 = AUTO;
+
199  b_servos_topright.txtcolor = WHITE;
+
200  b_servos_topright.bgcolor = HEX(0xAE1010);
+
201  b_servos_topright.font = 0;
+
202  b_servos_topright.text = "ToRi";
+
203  b_servos_topright.callback = b_servos_topright_cb;
+
204  gui_button_add(&b_servos_topright);
+
205 
+
206  b_servos_bottomleft.base.x1 = b_servos_topright.base.x2 + SERVO_BUTTON_SPACING;
+
207  b_servos_bottomleft.base.y1 = SERVO_BUTTON_Y - 3;
+
208  b_servos_bottomleft.base.x2 = AUTO;
+
209  b_servos_bottomleft.base.y2 = AUTO;
+
210  b_servos_bottomleft.txtcolor = WHITE;
+
211  b_servos_bottomleft.bgcolor = HEX(0xAE1010);
+
212  b_servos_bottomleft.font = 0;
+
213  b_servos_bottomleft.text = "BoLe";
+
214  b_servos_bottomleft.callback = b_servos_bottomleft_cb;
+
215  gui_button_add(&b_servos_bottomleft);
+
216 
+
217  b_servos_bottomright.base.x1 = b_servos_bottomleft.base.x2 + SERVO_BUTTON_SPACING;
+
218  b_servos_bottomright.base.y1 = SERVO_BUTTON_Y - 3;
+
219  b_servos_bottomright.base.x2 = AUTO;
+
220  b_servos_bottomright.base.y2 = AUTO;
+
221  b_servos_bottomright.txtcolor = WHITE;
+
222  b_servos_bottomright.bgcolor = HEX(0xAE1010);
+
223  b_servos_bottomright.font = 0;
+
224  b_servos_bottomright.text = "BoRi";
+
225  b_servos_bottomright.callback = b_servos_bottomright_cb;
+
226  gui_button_add(&b_servos_bottomright);
+
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;
+
234  b_led_off.base.y1 = LED_COLOR_BUTTON_Y - 3;
+
235  b_led_off.base.x2 = AUTO;
+
236  b_led_off.base.y2 = AUTO;
+
237  b_led_off.txtcolor = WHITE;
+
238  b_led_off.bgcolor = BLACK;
+
239  b_led_off.font = 0;
+
240  b_led_off.text = "Off";
+
241  b_led_off.callback = b_led_off_cb;
+
242  gui_button_add(&b_led_off);
+
243 
+
244  b_led_white.base.x1 = b_led_off.base.x2 + LED_COLOR_BUTTON_SPACING;
+
245  b_led_white.base.y1 = LED_COLOR_BUTTON_Y - 3;
+
246  b_led_white.base.x2 = AUTO;
+
247  b_led_white.base.y2 = AUTO;
+
248  b_led_white.txtcolor = BLACK;
+
249  b_led_white.bgcolor = HEX(0xEEEEEE);
+
250  b_led_white.font = 0;
+
251  b_led_white.text = "White";
+
252  b_led_white.callback = b_led_white_cb;
+
253  gui_button_add(&b_led_white);
+
254 
+
255  b_led_red.base.x1 = b_led_white.base.x2 + LED_COLOR_BUTTON_SPACING;
+
256  b_led_red.base.y1 = LED_COLOR_BUTTON_Y - 3;
+
257  b_led_red.base.x2 = AUTO;
+
258  b_led_red.base.y2 = AUTO;
+
259  b_led_red.txtcolor = WHITE;
+
260  b_led_red.bgcolor = HEX(0xEE0000);
+
261  b_led_red.font = 0;
+
262  b_led_red.text = "Red";
+
263  b_led_red.callback = b_led_red_cb;
+
264  gui_button_add(&b_led_red);
+
265 
+
266  b_led_green.base.x1 = b_led_red.base.x2 + LED_COLOR_BUTTON_SPACING;
+
267  b_led_green.base.y1 = LED_COLOR_BUTTON_Y - 3;
+
268  b_led_green.base.x2 = AUTO;
+
269  b_led_green.base.y2 = AUTO;
+
270  b_led_green.txtcolor = WHITE;
+
271  b_led_green.bgcolor = HEX(0x00EE00);
+
272  b_led_green.font = 0;
+
273  b_led_green.text = "Green";
+
274  b_led_green.callback = b_led_green_cb;
+
275  gui_button_add(&b_led_green);
+
276 
+
277  b_led_blue.base.x1 = b_led_green.base.x2 + LED_COLOR_BUTTON_SPACING;
+
278  b_led_blue.base.y1 = LED_COLOR_BUTTON_Y - 3;
+
279  b_led_blue.base.x2 = AUTO;
+
280  b_led_blue.base.y2 = AUTO;
+
281  b_led_blue.txtcolor = WHITE;
+
282  b_led_blue.bgcolor = HEX(0x0000EE);
+
283  b_led_blue.font = 0;
+
284  b_led_blue.text = "Blue";
+
285  b_led_blue.callback = b_led_blue_cb;
+
286  gui_button_add(&b_led_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;
+
294  n_led_powerlimit.y = LED_POWER_BUTTON_Y - 7;
+
295  n_led_powerlimit.fgcolor = WHITE;
+
296  n_led_powerlimit.value = 10;
+
297  n_led_powerlimit.max = 40;
+
298  n_led_powerlimit.min = 0;
+
299  n_led_powerlimit.callback = n_led_powerlimit_cb;
+
300  gui_numupdown_add(&n_led_powerlimit);
+
301 
+
302 
+
303 
+
304  state = detecting;
+
305 }
+
306 
+
307 static void leave(void* screen)
+
308 {
+
309  gui_button_remove(&b_back);
+
310  gui_button_remove(&b_servos_center);
+
311  gui_button_remove(&b_servos_topleft);
+
312  gui_button_remove(&b_servos_topright);
+
313  gui_button_remove(&b_servos_bottomleft);
+
314  gui_button_remove(&b_servos_bottomright);
+
315  gui_button_remove(&b_led_off);
+
316  gui_button_remove(&b_led_white);
+
317  gui_button_remove(&b_led_red);
+
318  gui_button_remove(&b_led_green);
+
319  gui_button_remove(&b_led_blue);
+
320  gui_numupdown_remove(&n_led_powerlimit);
+
321 
+
322 }
+
323 
+
324 
+
325 static void update(void* screen)
+
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 }
+
365 
+
366 
+ +
368  enter,
+
369  leave,
+
370  update
+
371 };
+
372 
+
373 
+ +
375 {
+
376  return &screen;
+
377 }
+
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)
+ +
#define INT32(v)
Definition: pixydefs.h:65
+
uint16_t x1
Top Left X-Coordinate of Area.
Definition: touch.h:74
+
static uint16_t servo_x
+
static void b_servos_topright_cb(void *button)
+
#define TRANSPARENT
Definition: tft.h:66
+
static void b_led_white_cb(void *button)
+
static SCREEN_STRUCT screen
+
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)
+
int pixy_service()
+ +
uint16_t y
The y-Coordinate of the Top-Left Starting Point.
Definition: numupdown.h:50
+
static uint32_t led_maxcurrent
+
static void b_servos_topleft_cb(void *button)
+
int16_t max
The maximum possible value (inclusive)
Definition: numupdown.h:54
+
SCREEN_STRUCT * get_screen_pixytest()
+ +
int pixy_command(const char *name,...)
Send a command to Pixy.
+ +
static BUTTON_STRUCT b_led_white
+ +
void tft_clear(uint16_t color)
Definition: tft.c:45
+
void gui_numupdown_remove(NUMUPDOWN_STRUCT *numupdown)
Definition: numupdown.c:136
+
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
+ +
void gui_button_remove(BUTTON_STRUCT *button)
Definition: button.c:184
+
static void b_led_red_cb(void *button)
+
int16_t min
The minimum possible value (inclusive)
Definition: numupdown.h:53
+
int pixy_led_set_max_current(uint32_t current)
Set pixy LED maximum current.
+ +
#define WHITE
Definition: tft.h:53
+
static void leave(void *screen)
+
static BUTTON_STRUCT b_servos_topleft
+ +
static NUMUPDOWN_STRUCT n_led_powerlimit
+
int pixy_init()
Creates a connection with Pixy and listens for Pixy messages.
+
static BUTTON_STRUCT b_back
+
#define END_OUT_ARGS
Definition: pixydefs.h:89
+
static enum @1 state
+
static void b_servos_bottomright_cb(void *button)
+
int pixy_rcs_set_position(uint8_t channel, uint16_t position)
Set pixy servo axis position.
+
uint16_t fgcolor
The 16-bit color of the value-text.
Definition: numupdown.h:51
+
static void update(void *screen)
+ +
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
+
static void enter(void *screen)
+
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
+
static uint32_t led_color
+
bool gui_screen_back()
Definition: screen.c:85
+ +
uint8_t font
The number of the font to use.
Definition: button.h:60
+
static BUTTON_STRUCT b_led_off
+
#define END_IN_ARGS
Definition: pixydefs.h:90
+ +
#define BLACK
Definition: tft.h:54
+
bool gui_numupdown_add(NUMUPDOWN_STRUCT *numupdown)
Definition: numupdown.c:80
+
static uint16_t servo_y
+
+ + + + diff --git a/screen__pixytest_8h.html b/screen__pixytest_8h.html index fb2fa6d..a65d253 100644 --- a/screen__pixytest_8h.html +++ b/screen__pixytest_8h.html @@ -117,7 +117,7 @@ Functions diff --git a/screen__pixytest_8h_source.html b/screen__pixytest_8h_source.html index 3035e0f..7321b56 100644 --- a/screen__pixytest_8h_source.html +++ b/screen__pixytest_8h_source.html @@ -89,19 +89,34 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
screen_pixytest.h
-Go to the documentation of this file.
1 #include "screen.h"
-
2 
-
7 
-
13 
- -
20 
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/app/screen_pixytest.h
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-04-27 timolang@gmail.com cf72baa Introduced a Screen (sub) module and divided app into multiple screens.
+
11 * 2015-05-10 timolang@gmail.com 21edc56 Added doxyfile (doxygen) for the common folder. Started with doxygen comments for app and tft module.
+
12 * 2015-05-15 timolang@gmail.com 9a16865 Added doxgen comments to filesyste, checkbox, numupdown and screen module. And some minor changes to the other modules.
+
13 *
+
14 **************************************************************************************************************************************/
+
15 
+
16 #include "screen.h"
+
17 
+
22 
+
28 
+ +
35 
-
SCREEN_STRUCT * get_screen_pixytest()
Definition: screen_pixytest.c:337
-
Definition: screen.h:34
+
SCREEN_STRUCT * get_screen_pixytest()
+
diff --git a/screen__tracking_8c.html b/screen__tracking_8c.html index bfc1ae9..d7826a0 100644 --- a/screen__tracking_8c.html +++ b/screen__tracking_8c.html @@ -112,7 +112,9 @@ Include dependency graph for screen_tracking.c:
- + +

Go to the source code of this file.

+
@@ -247,6 +249,8 @@ Variables

Data Structures

struct  TRACKING_CONFIG_STRUCT
+

Definition at line 70 of file screen_tracking.c.

+
@@ -259,6 +263,8 @@ Variables
+

Definition at line 71 of file screen_tracking.c.

+
@@ -271,6 +277,8 @@ Variables
+

Definition at line 69 of file screen_tracking.c.

+
@@ -283,6 +291,8 @@ Variables
+

Definition at line 66 of file screen_tracking.c.

+
@@ -295,6 +305,8 @@ Variables
+

Definition at line 67 of file screen_tracking.c.

+
@@ -307,6 +319,8 @@ Variables
+

Definition at line 68 of file screen_tracking.c.

+

Typedef Documentation

@@ -320,6 +334,8 @@ Variables
+

Definition at line 100 of file screen_tracking.c.

+
@@ -332,6 +348,8 @@ Variables
+

Definition at line 98 of file screen_tracking.c.

+

Enumeration Type Documentation

@@ -363,6 +381,18 @@ Variables +

Definition at line 48 of file screen_tracking.c.

+
48 {detecting, init, tracking, preselecting, abortselecting, selecting, selected, error} state; //Current state of the screen state machine
+ + + + + + + +
static enum @2 state
+ +

Function Documentation

@@ -388,6 +418,12 @@ Variables
+

Definition at line 36 of file screen_tracking.c.

+
37 {
+
38  gui_screen_back(); //navigate back to the previous screen
+
39 }
+
bool gui_screen_back()
Definition: screen.c:85
+

Here is the call graph for this function:
@@ -430,6 +466,20 @@ Here is the caller graph for this function:
+

Definition at line 55 of file screen_tracking.c.

+
56 {
+
57  if (state == selecting) { //we're currently selecting a color region
+
58  state = abortselecting; //Abort selecting!!
+
59  } else if (state == tracking) { //we're currently watching the tracking
+
60  state = preselecting; //start selecting
+
61  }
+
62 }
+ + + +
static enum @2 state
+ +

Here is the caller graph for this function:
@@ -473,6 +523,13 @@ Here is the caller graph for this function:
+

Definition at line 42 of file screen_tracking.c.

+
43 {
+
44  frame_visible = checked; //Set the visibility of the frame to the checked state of the checkbox
+
45  //Frame will be drawn in the main loop below
+
46 }
+
static volatile bool frame_visible
+

Here is the caller graph for this function:
@@ -506,6 +563,108 @@ Here is the caller graph for this function:
+

Definition at line 229 of file screen_tracking.c.

+
230 {
+
231  tft_clear(WHITE);
+
232 
+
233  //"Back" button
+
234  b_back.base.x1 = 5; //Start X of Button
+
235  b_back.base.y1 = 5; //Start Y of Button
+
236  b_back.base.x2 = AUTO; //Auto Calculate X2 with String Width
+
237  b_back.base.y2 = AUTO; //Auto Calculate Y2 with String Height
+
238  b_back.txtcolor = WHITE; //Set foreground color
+
239  b_back.bgcolor = HEX(0xAE1010); //Set background color (Don't take 255 or 0 on at least one channel, to make shadows possible)
+
240  b_back.font = 0; //Select Font
+
241  b_back.text = "Back"; //Set Text (For formatted strings take sprintf)
+
242  b_back.callback = b_back_cb; //Call b_back_cb as Callback
+
243  gui_button_add(&b_back); //Register Button (and run the callback from now on)
+
244 
+
245 
+
246  //"Select color" button
+
247  b_select.base.x1 = 150;
+
248  b_select.base.y1 = 5;
+
249  b_select.base.x2 = AUTO;
+
250  b_select.base.y2 = AUTO;
+ +
252  b_select.bgcolor = HEX(0xAE1010);
+
253  b_select.font = 0;
+
254  b_select.text = "Select Color";
+ + +
257 
+
258  //"Frame visible" checkbox
+
259  c_frame_toggle.base.x1 = 50;
+
260  c_frame_toggle.base.x2 = 50 + 16;
+
261  c_frame_toggle.base.y1 = 5;
+
262  c_frame_toggle.base.y2 = 5 + 16;
+ + + + +
267  tft_print_line(73, 8, BLACK, TRANSPARENT, 0, "Show Video");
+
268 
+
269 
+
270  //Area to select a "color region"
+ + + + + + +
277  //Do not register it here, we do that later
+
278 
+
279  if (tracking_current == NULL) {
+
280  state = error;
+
281  } else {
+
282  state = detecting; //Start with the detecting state
+
283  }
+
284 }
+
const char * text
The label of the button.
Definition: button.h:61
+
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
+
Receive an event when the pen goes down inside the region.
Definition: touch.h:54
+
Receive an event when the pen goes up inside the region.
Definition: touch.h:55
+
bool gui_checkbox_add(CHECKBOX_STRUCT *checkbox)
Definition: checkbox.c:70
+
uint16_t y1
Top Left Y-Coordinate of Area.
Definition: touch.h:75
+
#define FRAME_START_Y
+
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
+
uint16_t x1
Top Left X-Coordinate of Area.
Definition: touch.h:74
+
bool checked
A boolean which indicates whether or not the checkbox is currently checked.
Definition: checkbox.h:53
+
#define TRANSPARENT
Definition: tft.h:66
+
static TRACKING_CONFIG_STRUCT * tracking_current
+
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 HEX(h)
Definition: tft.h:60
+
uint16_t y2
Bottom Right Y-Coordinate of Area.
Definition: touch.h:77
+
static void c_frame_toggle_cb(void *checkbox, bool checked)
+
TOUCH_CALLBACK callback
Callback which is executed when an event occurred in this Area.
Definition: touch.h:78
+
void tft_clear(uint16_t color)
Definition: tft.c:45
+
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
+
#define CHECKBOX_WIN_FG_COLOR
Definition: checkbox.h:82
+
static BUTTON_STRUCT b_select
+
#define WHITE
Definition: tft.h:53
+
#define FRAME_END_Y
+
static TOUCH_AREA_STRUCT a_area
+
static volatile bool frame_visible
+
TOUCH_ACTION hookedActions
Actions to listen to.
Definition: touch.h:73
+ +
TOUCH_AREA_STRUCT base
Basic geometry of the Checkbox. You only need to set the x1, y1, x2, y2 members of this struct...
Definition: checkbox.h:51
+
#define FRAME_END_X
+
static void b_select_cb(void *button)
+
static enum @2 state
+
uint16_t fgcolor
The 16-bit color of the tickmark.
Definition: checkbox.h:52
+
#define FRAME_START_X
+
static BUTTON_STRUCT b_back
+
BUTTON_CALLBACK callback
Callback which is executed when the button is pressed.
Definition: button.h:58
+
static CHECKBOX_STRUCT c_frame_toggle
+
CHECKBOX_CALLBACK callback
Callback which is executed when the checkbox changes state.
Definition: checkbox.h:54
+
uint8_t font
The number of the font to use.
Definition: button.h:60
+
static void b_back_cb(void *button)
+
static void touchCB(void *touchArea, TOUCH_ACTION triggeredAction)
+
#define BLACK
Definition: tft.h:54
+

Here is the call graph for this function:
@@ -539,6 +698,36 @@ Here is the call graph for this function:
+

Definition at line 287 of file screen_tracking.c.

+
288 {
+
289  //Remove buttons and checkbox
+ + + +
293 
+
294  if (state == selecting) { //the user left the screen in the "selecting" phase
+
295  touch_unregister_area(&a_area); //remove the touch area
+
296  }
+
297 
+
298  if (state == tracking) { //the user left the screen in the "tracking" phase
+
299  tracking_current->stop(tracking_current); //stop tracking
+
300  pixy_led_set_RGB(0, 0, 0);
+
301  }
+
302 }
+
void gui_checkbox_remove(CHECKBOX_STRUCT *checkbox)
Definition: checkbox.c:119
+
static TRACKING_CONFIG_STRUCT * tracking_current
+
void touch_unregister_area(TOUCH_AREA_STRUCT *area)
Definition: touch.c:195
+ +
void gui_button_remove(BUTTON_STRUCT *button)
Definition: button.c:184
+
static BUTTON_STRUCT b_select
+
TRACKING_VOID_CALLBACK stop
+
static TOUCH_AREA_STRUCT a_area
+
static enum @2 state
+
static BUTTON_STRUCT b_back
+
static CHECKBOX_STRUCT c_frame_toggle
+ +
int pixy_led_set_RGB(uint8_t red, uint8_t green, uint8_t blue)
Set color of pixy LED.
+

Here is the call graph for this function:
@@ -582,6 +771,41 @@ Here is the call graph for this function:
+

Definition at line 75 of file screen_tracking.c.

+
76 {
+ +
78 
+
79  switch (triggeredAction) {
+
80  case PEN_DOWN: //The user just put down the pen
+
81  point1.x = p.x - FRAME_START_X; //Calculate x-Coordinate relative to frame start
+
82  point1.y = p.y - FRAME_START_Y; //Calculate y-Coordinate relative to frame start
+
83  point1_valid = true; //The point1 is now valid
+
84  break;
+
85 
+
86  case PEN_UP: //The user took the pen away
+
87  if (point1_valid) { //only execute if point1 is valid
+
88  point2.x = p.x - FRAME_START_X; //Calculate x-Coordinate relative to frame start
+
89  point2.y = p.y - FRAME_START_Y; //Calculate y-Coordinate relative to frame start
+
90  state = selected;
+
91  }
+
92 
+
93  break;
+
94  }
+
95 }
+
Receive an event when the pen goes down inside the region.
Definition: touch.h:54
+
Receive an event when the pen goes up inside the region.
Definition: touch.h:55
+
uint16_t y
The Y-Coordinate of the point.
Definition: touch.h:88
+ +
#define FRAME_START_Y
+
uint16_t x
The X-Coordinate of the point.
Definition: touch.h:87
+
static POINT_STRUCT point1
+
POINT_STRUCT touch_get_last_point()
Definition: touch.c:211
+ +
static bool point1_valid
+
static enum @2 state
+
#define FRAME_START_X
+
static POINT_STRUCT point2
+

Here is the call graph for this function:
@@ -616,6 +840,26 @@ Here is the caller graph for this function:
+

Definition at line 114 of file screen_tracking.c.

+
115 {
+
116  //Activate pixy's data send program
+
117  int32_t response;
+
118  int return_value;
+
119 
+
120  servo_x = servo_y = 500; // set a default value of 500
+
121  pixy_rcs_set_position(0, servo_x); // set default
+
122  pixy_rcs_set_position(1, servo_y); // set default
+
123 
+
124  return_value = pixy_command("runprog", INT8(0), END_OUT_ARGS, &response, END_IN_ARGS);
+
125 }
+
int pixy_command(const char *name,...)
Send a command to Pixy.
+
#define END_OUT_ARGS
Definition: pixydefs.h:89
+
int pixy_rcs_set_position(uint8_t channel, uint16_t position)
Set pixy servo axis position.
+
static int16_t servo_y
+
static int16_t servo_x
+
#define END_IN_ARGS
Definition: pixydefs.h:90
+
#define INT8(v)
Definition: pixydefs.h:61
+

Here is the call graph for this function:
@@ -641,6 +885,17 @@ Here is the call graph for this function:
+

Definition at line 128 of file screen_tracking.c.

+
129 {
+
130  //Stop pixy's data send programm
+
131  int32_t response;
+
132  int return_value;
+
133  return_value = pixy_command("stop", END_OUT_ARGS, &response, END_IN_ARGS);
+
134 }
+
int pixy_command(const char *name,...)
Send a command to Pixy.
+
#define END_OUT_ARGS
Definition: pixydefs.h:89
+
#define END_IN_ARGS
Definition: pixydefs.h:90
+

Here is the call graph for this function:
@@ -682,6 +937,44 @@ Here is the call graph for this function:
+

Definition at line 137 of file screen_tracking.c.

+
138 {
+
139 
+
140  if (num_blocks <= 0) { // Check if there are blocks available
+
141  return; // When there are none, do nothing
+
142  }
+
143 
+
144  uint16_t x = blocks[0].x; // Get x coordinate of the biggest object
+
145  uint16_t y = blocks[0].y; // Get y coordinate of the biggest object
+
146 
+
147  int16_t xset = 0;
+
148  int16_t yset = 0;
+
149 
+
150  xset = (servo_x + pixy_PID_X((FRAME_WIDTH / 2), x)); // calculate the PID output for x
+
151  yset = (servo_y - pixy_PID_Y((FRAME_HEIGHT / 2), y)); // calculate the PID output for y
+
152 
+
153  xset = (xset < 0) ? 0 : xset; // x lower boundary check
+
154  xset = (xset > 1000) ? 1000 : xset; // x upper boundary check
+
155 
+
156  yset = (yset < 0) ? 0 : yset; // y lower boundary check
+
157  yset = (yset > 1000) ? 1000 : yset; // y upper boundary check
+
158 
+
159  servo_x = xset; // update the global, static variable for x
+
160  servo_y = yset; // update the global, statuc variable for y
+
161 
+
162  pixy_rcs_set_position(0, servo_x); // set the new x position
+
163  pixy_rcs_set_position(1, servo_y); // set the new y position
+
164 }
+
#define FRAME_HEIGHT
+
uint16_t y
Definition: pixy.h:81
+
int16_t pixy_PID_X(int16_t x, int16_t w)
Definition: pixy_control.c:67
+
int pixy_rcs_set_position(uint8_t channel, uint16_t position)
Set pixy servo axis position.
+
static int16_t servo_y
+
static int16_t servo_x
+
#define FRAME_WIDTH
+
int16_t pixy_PID_Y(int16_t x, int16_t w)
Definition: pixy_control.c:44
+
uint16_t x
Definition: pixy.h:80
+

Here is the call graph for this function:
@@ -707,6 +1000,18 @@ Here is the call graph for this function:
+

Definition at line 176 of file screen_tracking.c.

+
177 {
+
178  //Run reference tracking
+
179  int32_t response;
+
180  int return_value;
+
181  return_value = pixy_command("runprog", INT8(2), END_OUT_ARGS, &response, END_IN_ARGS);
+
182 }
+
int pixy_command(const char *name,...)
Send a command to Pixy.
+
#define END_OUT_ARGS
Definition: pixydefs.h:89
+
#define END_IN_ARGS
Definition: pixydefs.h:90
+
#define INT8(v)
Definition: pixydefs.h:61
+

Here is the call graph for this function:
@@ -732,6 +1037,17 @@ Here is the call graph for this function:
+

Definition at line 185 of file screen_tracking.c.

+
186 {
+
187  //Stop reference tracking
+
188  int32_t response;
+
189  int return_value;
+
190  return_value = pixy_command("stop", END_OUT_ARGS, &response, END_IN_ARGS);
+
191 }
+
int pixy_command(const char *name,...)
Send a command to Pixy.
+
#define END_OUT_ARGS
Definition: pixydefs.h:89
+
#define END_IN_ARGS
Definition: pixydefs.h:90
+

Here is the call graph for this function:
@@ -773,6 +1089,11 @@ Here is the call graph for this function:
+

Definition at line 194 of file screen_tracking.c.

+
195 {
+
196  //Nothing to do here. Pixy does it all.
+
197 }
+
@@ -797,6 +1118,155 @@ Here is the call graph for this function:
+

Definition at line 306 of file screen_tracking.c.

+
307 {
+
308  switch (state) {
+
309  case detecting: //Detecting State: Where we try to connect to the pixy
+
310  if (pixy_init() == 0) { //Pixy connection ok
+
311  state = init; //Go to next state
+
312  }
+
313 
+
314  break;
+
315 
+
316  case init: //Init State: Where we start the tracking
+ +
318  state = tracking;
+
319  break;
+
320 
+
321  case tracking: //Tracking state: Where we render the frame and the tracked objects
+
322  pixy_service(); //Receive events (e.g. block-data) from pixy
+
323 
+
324  if (pixy_blocks_are_new()) { //There are new blocks available
+
325  if (frame_visible) { //If the user want's us to draw the video data
+ +
327  } else { //the user want's a colored background
+ +
329  }
+
330 
+
331 #define BLOCK_BUFFER_SIZE 5 //The maximum amount of blocks that we want to receive
+
332  struct Block blocks[BLOCK_BUFFER_SIZE]; //Storage to receive blocks from pixy
+
333  int blocks_received = pixy_get_blocks(BLOCK_BUFFER_SIZE, blocks); //Try to receive up to BLOCK_BUFFER_SIZE Blocks from pixy
+
334 
+
335  if (blocks_received >= 0) { //block receiving ok
+
336  tracking_current->update(tracking_current, blocks, blocks_received); //apply tracking
+
337 
+
338  //Draw blocks
+
339  for (int i = 0; i < blocks_received; i++) { //for each received block
+
340  struct Block* block = &(blocks[i]);
+
341  //block.x and block.y are the center coordinates of the object relative to the camera origin.
+
342  uint16_t x = block->x - 1 + FRAME_START_X - block->width / 2; //Calculate x-Coordinate on the display
+
343  uint16_t y = block->y - 1 + FRAME_START_Y - block->height / 2; //Calculate y-Coordinate on the display
+
344  tft_draw_rectangle(x, y, x + block->width - 1, y + block->height - 1, WHITE); //Draw a white rectangle
+
345  }
+
346  }
+
347  }
+
348 
+
349  break;
+
350 
+
351  case preselecting: { //Pre-Selecting State: Where we set up the color region selection
+
352  tracking_current->stop(tracking_current); //Stop tracking
+
353 
+ +
355 
+
356  touch_register_area(&a_area); //Register touch area and receive events from now on
+
357  point1_valid = false; //we start with an invalid point1
+
358 
+
359  b_select.text = "Abort"; //Change the button text to "Abort"
+
360  gui_button_redraw(&b_select); //redraw button
+
361 
+
362  state = selecting; //The user can now select a region
+
363  }
+
364  break;
+
365 
+
366  case selected: { //Selected State: Where we send the users selection to pixy
+
367  //Ensure that (x1,y1) represent the top-left point and (x2,y2) the bottom-right.
+
368  unsigned int tmp;
+
369 
+
370  if (point1.x > point2.x) {
+
371  tmp = point1.x;
+
372  point1.x = point2.x;
+
373  point2.x = tmp;
+
374  }
+
375 
+
376  if (point1.y > point2.y) {
+
377  tmp = point1.y;
+
378  point1.y = point2.y;
+
379  point2.y = tmp;
+
380  }
+
381 
+
382  //Send pixy the selected region
+ +
384  }
+
385 
+
386  //no break here: We want the following code to be executed as well
+
387 
+
388  case abortselecting: { //Abort-Selecting State: Where we deinitialize the stuff we used for region selection
+
389  touch_unregister_area(&a_area); //Remove the touch area. We'll no longer receive touch events
+
390 
+
391  b_select.text = "Select Color"; //Change the button text back to "Select Color"
+
392  gui_button_redraw(&b_select); //redraw button
+
393 
+
394  tracking_current->start(tracking_current); //Start tracking again
+
395  state = tracking;
+
396  }
+
397  break;
+
398 
+
399  case selecting: //Selecting State: Where we wait on the user to select a color region
+
400  pixy_service(); //receive pixy events
+
401  //wait on user to select the image area
+
402  break;
+
403 
+
404  case error: //Error State: Where we show an error message and leave the user no other choice than to click the backbutton
+
405  //wait on user to click the back button
+
406  break;
+
407  }
+
408 }
+
bool touch_register_area(TOUCH_AREA_STRUCT *area)
Definition: touch.c:181
+
const char * text
The label of the button.
Definition: button.h:61
+
void gui_button_redraw(BUTTON_STRUCT *button)
Definition: button.c:164
+
uint16_t y
The Y-Coordinate of the point.
Definition: touch.h:88
+ +
#define FRAME_START_Y
+ +
#define RGB(r, g, b)
Definition: tft.h:48
+
uint16_t x
The X-Coordinate of the point.
Definition: touch.h:87
+
uint16_t y
Definition: pixy.h:81
+ +
static TRACKING_CONFIG_STRUCT * tracking_current
+
void touch_unregister_area(TOUCH_AREA_STRUCT *area)
Definition: touch.c:195
+ +
int pixy_blocks_are_new()
Indicates when new block data from Pixy is received.
+
int pixy_service()
+ +
uint16_t height
Definition: pixy.h:83
+
TRACKING_VOID_CALLBACK start
+
static BUTTON_STRUCT b_select
+
#define WHITE
Definition: tft.h:53
+
static POINT_STRUCT point1
+
TRACKING_VOID_CALLBACK stop
+
void tft_fill_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:67
+
#define FRAME_END_Y
+
static TOUCH_AREA_STRUCT a_area
+
int pixy_init()
Creates a connection with Pixy and listens for Pixy messages.
+
static volatile bool frame_visible
+
uint16_t width
Definition: pixy.h:82
+ +
void tft_draw_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:61
+ +
TRACKING_BLOCK_CALLBACK update
+
#define FRAME_END_X
+
static bool point1_valid
+
static enum @2 state
+
#define BLOCK_BUFFER_SIZE
+
#define FRAME_START_X
+
int pixy_render_full_frame(uint16_t x, uint16_t y)
Definition: pixy_frame.c:25
+ +
int pixy_cc_set_region(uint8_t signum, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
Definition: pixy_frame.c:233
+
static POINT_STRUCT point2
+
int pixy_get_blocks(uint16_t max_blocks, struct Block *blocks)
Copies up to 'max_blocks' number of Blocks to the address pointed to by 'blocks'. ...
+
uint16_t x
Definition: pixy.h:80
+
Definition: pixy.h:53
+

Here is the call graph for this function:
@@ -827,6 +1297,8 @@ Here is the call graph for this function:
+

Definition at line 33 of file screen_tracking.c.

+
@@ -847,6 +1319,8 @@ Here is the call graph for this function:
+

Definition at line 30 of file screen_tracking.c.

+
@@ -867,6 +1341,8 @@ Here is the call graph for this function:
+

Definition at line 31 of file screen_tracking.c.

+
@@ -887,6 +1363,8 @@ Here is the call graph for this function:
+

Definition at line 32 of file screen_tracking.c.

+
@@ -907,6 +1385,8 @@ Here is the call graph for this function:
+

Definition at line 41 of file screen_tracking.c.

+
@@ -927,6 +1407,8 @@ Here is the call graph for this function:
+

Definition at line 50 of file screen_tracking.c.

+
@@ -947,6 +1429,8 @@ Here is the call graph for this function:
+

Definition at line 52 of file screen_tracking.c.

+
@@ -967,6 +1451,8 @@ Here is the call graph for this function:
+

Definition at line 51 of file screen_tracking.c.

+
@@ -991,10 +1477,12 @@ Here is the call graph for this function:
leave,
update
}
-
static void leave(void *screen)
Definition: screen_tracking.c:251
-
static void update(void *screen)
Definition: screen_tracking.c:269
-
static void enter(void *screen)
Definition: screen_tracking.c:194
+
static void leave(void *screen)
+
static void update(void *screen)
+
static void enter(void *screen)
+

Definition at line 411 of file screen_tracking.c.

+ @@ -1015,6 +1503,8 @@ Here is the call graph for this function:
+

Definition at line 110 of file screen_tracking.c.

+
@@ -1035,6 +1525,8 @@ Here is the call graph for this function:
+

Definition at line 111 of file screen_tracking.c.

+
@@ -1067,6 +1559,8 @@ Here is the call graph for this function:
+

Definition at line 207 of file screen_tracking.c.

+
@@ -1087,14 +1581,16 @@ Here is the call graph for this function:
Initial value:
= {
- - - + + +
}
-
void tracking_our_update(void *tracking_config, struct Block *blocks, int num_blocks)
Definition: screen_tracking.c:109
-
void tracking_our_stop(void *tracking_config)
Definition: screen_tracking.c:101
-
void tracking_our_start(void *tracking_config)
Definition: screen_tracking.c:88
+
void tracking_our_update(void *tracking_config, struct Block *blocks, int num_blocks)
+
void tracking_our_stop(void *tracking_config)
+
void tracking_our_start(void *tracking_config)
+

Definition at line 167 of file screen_tracking.c.

+
@@ -1115,20 +1611,22 @@ Here is the call graph for this function:
Initial value:
= {
- - - + + +
}
-
void tracking_reference_stop(void *tracking_config)
Definition: screen_tracking.c:155
-
void tracking_reference_update(void *tracking_config, struct Block *blocks, int num_blocks)
Definition: screen_tracking.c:163
-
void tracking_reference_start(void *tracking_config)
Definition: screen_tracking.c:147
+
void tracking_reference_stop(void *tracking_config)
+
void tracking_reference_update(void *tracking_config, struct Block *blocks, int num_blocks)
+
void tracking_reference_start(void *tracking_config)
+

Definition at line 200 of file screen_tracking.c.

+
diff --git a/screen__tracking_8c_source.html b/screen__tracking_8c_source.html new file mode 100644 index 0000000..4e270f9 --- /dev/null +++ b/screen__tracking_8c_source.html @@ -0,0 +1,648 @@ + + + + + + +discoverpixy: common/app/screen_tracking.c Source File + + + + + + + + + + +
+
+ + + + + + +
+
discoverpixy +
+
+
+ + + + + + +
+
+ + +
+ +
+ + +
+
+
+
screen_tracking.c
+
+
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/app/screen_tracking.c
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-05-16 timolang@gmail.com e46314b Added Tracking Screen and implemented "Reference Tracking" and "Color Region Selection"
+
11 * 2015-05-25 timolang@gmail.com 8088014 Updated Tracking Screen so that the implementations are separated into different method groups.
+
12 * 2015-06-06 aaron@duckpond.ch 8c264c2 Comment refactoring, updated PID values
+
13 * 2015-06-06 aaron@duckpond.ch a04cda9 Refactured comments and implemented a bugfix for the PID controller
+
14 * 2015-06-07 aaron@duckpond.ch 802d3df Fixed pid controller and refactored code
+
15 * 2015-06-07 aaron@duckpond.ch 3d98ca9 Minor changes
+
16 * 2015-06-07 timolang@gmail.com c87220d Renamed pixy_helper to pixy_frame. Updated docu of appliaction. added doxygen comments to pixy_{frame,control}.h
+
17 *
+
18 **************************************************************************************************************************************/
+
19 
+
20 #include "screen_tracking.h"
+
21 #include "pixy_control.h"
+
22 #include "button.h"
+
23 #include "checkbox.h"
+
24 #include "tft.h"
+
25 #include "touch.h"
+
26 #include "pixy.h"
+
27 #include "system.h"
+
28 #include "pixy_frame.h"
+
29 
+
30 static BUTTON_STRUCT b_back; //Button to navigate back
+
31 static BUTTON_STRUCT b_select; //Button to start the color region selection
+
32 static CHECKBOX_STRUCT c_frame_toggle; //Checkbox to toggle video data on/off
+
33 static TOUCH_AREA_STRUCT a_area; //Touch area for the color region selection
+
34 
+
35 //Callback for when the user presses the "back" button
+
36 static void b_back_cb(void* button)
+
37 {
+
38  gui_screen_back(); //navigate back to the previous screen
+
39 }
+
40 
+
41 static volatile bool frame_visible = false; //Whether or not the video data should be displayed
+
42 static void c_frame_toggle_cb(void* checkbox, bool checked)
+
43 {
+
44  frame_visible = checked; //Set the visibility of the frame to the checked state of the checkbox
+
45  //Frame will be drawn in the main loop below
+
46 }
+
47 
+
48 static enum {detecting, init, tracking, preselecting, abortselecting, selecting, selected, error} state; //Current state of the screen state machine
+
49 
+
50 static POINT_STRUCT point1; //First point of the rectangle selected by the user (color region selection)
+
51 static POINT_STRUCT point2; //End point of the rectangle selected by the user (color region selection)
+
52 static bool point1_valid; //Whether or not we have a valid first point
+
53 
+
54 //Callback for when the user presses the "select color" button
+
55 static void b_select_cb(void* button)
+
56 {
+
57  if (state == selecting) { //we're currently selecting a color region
+
58  state = abortselecting; //Abort selecting!!
+
59  } else if (state == tracking) { //we're currently watching the tracking
+
60  state = preselecting; //start selecting
+
61  }
+
62 }
+
63 
+
64 //Video Region properties
+
65 //The camera records with 320*200px, but we need to keep a 1px border because of color interpolation (bayer format)
+
66 #define FRAME_START_X 1 //x-Coordinate of the top-left point of the frame rectangle on display
+
67 #define FRAME_START_Y 41 //y-Coordinate of the top-left point of the frame rectangle on display
+
68 #define FRAME_WIDTH 318 //Width of the video frame
+
69 #define FRAME_HEIGHT 198 //Height of the video frame
+
70 #define FRAME_END_X FRAME_START_X +FRAME_WIDTH-1 //x-Coordinate of the bottom-right point of the frame rectangle
+
71 #define FRAME_END_Y FRAME_START_Y +FRAME_HEIGHT-1 //y-Coordinate of the bottom-right point of the frame rectangle
+
72 
+
73 //Callback for when the user touches the frame area to select a color region.
+
74 //Note: It doesn't matter in which direction the user draws the rectangle, we'll normalize the coordinates later
+
75 static void touchCB(void* touchArea, TOUCH_ACTION triggeredAction)
+
76 {
+ +
78 
+
79  switch (triggeredAction) {
+
80  case PEN_DOWN: //The user just put down the pen
+
81  point1.x = p.x - FRAME_START_X; //Calculate x-Coordinate relative to frame start
+
82  point1.y = p.y - FRAME_START_Y; //Calculate y-Coordinate relative to frame start
+
83  point1_valid = true; //The point1 is now valid
+
84  break;
+
85 
+
86  case PEN_UP: //The user took the pen away
+
87  if (point1_valid) { //only execute if point1 is valid
+
88  point2.x = p.x - FRAME_START_X; //Calculate x-Coordinate relative to frame start
+
89  point2.y = p.y - FRAME_START_Y; //Calculate y-Coordinate relative to frame start
+
90  state = selected;
+
91  }
+
92 
+
93  break;
+
94  }
+
95 }
+
96 
+
97 //Prototype for tracking start/stop methods
+
98 typedef void (*TRACKING_VOID_CALLBACK)(void* tracking_config);
+
99 //Prototype for tracking update method
+
100 typedef void (*TRACKING_BLOCK_CALLBACK)(void* tracking_config, struct Block* blocks, int num_blocks);
+
101 
+
102 //Structure to save callbacks and settings of a tracking implementation
+
103 typedef struct {
+ + + + +
108 
+
109 //Methods for our tracking implementation ahead
+
110 static int16_t servo_x = 0;
+
111 static int16_t servo_y = 0;
+
112 
+
113 //Method/Callback to start our tracking
+
114 void tracking_our_start(void* tracking_config)
+
115 {
+
116  //Activate pixy's data send program
+
117  int32_t response;
+
118  int return_value;
+
119 
+
120  servo_x = servo_y = 500; // set a default value of 500
+
121  pixy_rcs_set_position(0, servo_x); // set default
+
122  pixy_rcs_set_position(1, servo_y); // set default
+
123 
+
124  return_value = pixy_command("runprog", INT8(0), END_OUT_ARGS, &response, END_IN_ARGS);
+
125 }
+
126 
+
127 //Method/Callback to stop our tracking
+
128 void tracking_our_stop(void* tracking_config)
+
129 {
+
130  //Stop pixy's data send programm
+
131  int32_t response;
+
132  int return_value;
+
133  return_value = pixy_command("stop", END_OUT_ARGS, &response, END_IN_ARGS);
+
134 }
+
135 
+
136 //Method/Callback to calculate one step of our tracking
+
137 void tracking_our_update(void* tracking_config, struct Block* blocks, int num_blocks)
+
138 {
+
139 
+
140  if (num_blocks <= 0) { // Check if there are blocks available
+
141  return; // When there are none, do nothing
+
142  }
+
143 
+
144  uint16_t x = blocks[0].x; // Get x coordinate of the biggest object
+
145  uint16_t y = blocks[0].y; // Get y coordinate of the biggest object
+
146 
+
147  int16_t xset = 0;
+
148  int16_t yset = 0;
+
149 
+
150  xset = (servo_x + pixy_PID_X((FRAME_WIDTH / 2), x)); // calculate the PID output for x
+
151  yset = (servo_y - pixy_PID_Y((FRAME_HEIGHT / 2), y)); // calculate the PID output for y
+
152 
+
153  xset = (xset < 0) ? 0 : xset; // x lower boundary check
+
154  xset = (xset > 1000) ? 1000 : xset; // x upper boundary check
+
155 
+
156  yset = (yset < 0) ? 0 : yset; // y lower boundary check
+
157  yset = (yset > 1000) ? 1000 : yset; // y upper boundary check
+
158 
+
159  servo_x = xset; // update the global, static variable for x
+
160  servo_y = yset; // update the global, statuc variable for y
+
161 
+
162  pixy_rcs_set_position(0, servo_x); // set the new x position
+
163  pixy_rcs_set_position(1, servo_y); // set the new y position
+
164 }
+
165 
+
166 //Variable which stores all the callbacks and settings for our tracking implementation
+ + + + +
171 };
+
172 
+
173 //Methods for reference tracking implementation ahead
+
174 
+
175 //Method/Callback to start reference tracking
+
176 void tracking_reference_start(void* tracking_config)
+
177 {
+
178  //Run reference tracking
+
179  int32_t response;
+
180  int return_value;
+
181  return_value = pixy_command("runprog", INT8(2), END_OUT_ARGS, &response, END_IN_ARGS);
+
182 }
+
183 
+
184 //Method/Callback to stop reference tracking
+
185 void tracking_reference_stop(void* tracking_config)
+
186 {
+
187  //Stop reference tracking
+
188  int32_t response;
+
189  int return_value;
+
190  return_value = pixy_command("stop", END_OUT_ARGS, &response, END_IN_ARGS);
+
191 }
+
192 
+
193 //Method/Callback to calculate one step of the reference tracking
+
194 void tracking_reference_update(void* tracking_config, struct Block* blocks, int num_blocks)
+
195 {
+
196  //Nothing to do here. Pixy does it all.
+
197 }
+
198 
+
199 //Variable which stores all the callbacks and settings for the reference tracking implementation
+ + + + +
204 };
+
205 
+
206 //Pointer to the currently active tracking implementation. See also tracking_set_mode
+ +
208 
+
209 //Method to set the current tracking implementation. This function is exported and should be called before getting the screen
+ +
211 {
+
212  //Depending on the enum value let tracking_current point to a different setting/callback structure
+
213  switch (impl) {
+
214  case OUR_TRACKING:
+
215  tracking_current = &tracking_our;
+
216  break;
+
217 
+
218  case REFERENCE_TRACKING:
+
219  tracking_current = &tracking_reference;
+
220  break;
+
221 
+
222  default:
+
223  tracking_current = NULL;
+
224  break;
+
225  }
+
226 }
+
227 
+
228 //Callback for when the screen is entered/loaded
+
229 static void enter(void* screen)
+
230 {
+
231  tft_clear(WHITE);
+
232 
+
233  //"Back" button
+
234  b_back.base.x1 = 5; //Start X of Button
+
235  b_back.base.y1 = 5; //Start Y of Button
+
236  b_back.base.x2 = AUTO; //Auto Calculate X2 with String Width
+
237  b_back.base.y2 = AUTO; //Auto Calculate Y2 with String Height
+
238  b_back.txtcolor = WHITE; //Set foreground color
+
239  b_back.bgcolor = HEX(0xAE1010); //Set background color (Don't take 255 or 0 on at least one channel, to make shadows possible)
+
240  b_back.font = 0; //Select Font
+
241  b_back.text = "Back"; //Set Text (For formatted strings take sprintf)
+
242  b_back.callback = b_back_cb; //Call b_back_cb as Callback
+
243  gui_button_add(&b_back); //Register Button (and run the callback from now on)
+
244 
+
245 
+
246  //"Select color" button
+
247  b_select.base.x1 = 150;
+
248  b_select.base.y1 = 5;
+
249  b_select.base.x2 = AUTO;
+
250  b_select.base.y2 = AUTO;
+
251  b_select.txtcolor = WHITE;
+
252  b_select.bgcolor = HEX(0xAE1010);
+
253  b_select.font = 0;
+
254  b_select.text = "Select Color";
+
255  b_select.callback = b_select_cb;
+
256  gui_button_add(&b_select);
+
257 
+
258  //"Frame visible" checkbox
+
259  c_frame_toggle.base.x1 = 50;
+
260  c_frame_toggle.base.x2 = 50 + 16;
+
261  c_frame_toggle.base.y1 = 5;
+
262  c_frame_toggle.base.y2 = 5 + 16;
+
263  c_frame_toggle.checked = frame_visible;
+
264  c_frame_toggle.fgcolor = CHECKBOX_WIN_FG_COLOR;
+
265  c_frame_toggle.callback = c_frame_toggle_cb;
+
266  gui_checkbox_add(&c_frame_toggle);
+
267  tft_print_line(73, 8, BLACK, TRANSPARENT, 0, "Show Video");
+
268 
+
269 
+
270  //Area to select a "color region"
+
271  a_area.hookedActions = PEN_DOWN | PEN_UP;
+
272  a_area.x1 = FRAME_START_X;
+
273  a_area.y1 = FRAME_START_Y;
+
274  a_area.x2 = FRAME_END_X;
+
275  a_area.y2 = FRAME_END_Y;
+
276  a_area.callback = touchCB;
+
277  //Do not register it here, we do that later
+
278 
+
279  if (tracking_current == NULL) {
+
280  state = error;
+
281  } else {
+
282  state = detecting; //Start with the detecting state
+
283  }
+
284 }
+
285 
+
286 //Callback for when the screen is left/unloaded
+
287 static void leave(void* screen)
+
288 {
+
289  //Remove buttons and checkbox
+
290  gui_button_remove(&b_back);
+
291  gui_button_remove(&b_select);
+
292  gui_checkbox_remove(&c_frame_toggle);
+
293 
+
294  if (state == selecting) { //the user left the screen in the "selecting" phase
+
295  touch_unregister_area(&a_area); //remove the touch area
+
296  }
+
297 
+
298  if (state == tracking) { //the user left the screen in the "tracking" phase
+
299  tracking_current->stop(tracking_current); //stop tracking
+
300  pixy_led_set_RGB(0, 0, 0);
+
301  }
+
302 }
+
303 
+
304 //Callback for when the screen should be updated
+
305 //This is the main loop of the screen. This method will be called repeatedly
+
306 static void update(void* screen)
+
307 {
+
308  switch (state) {
+
309  case detecting: //Detecting State: Where we try to connect to the pixy
+
310  if (pixy_init() == 0) { //Pixy connection ok
+
311  state = init; //Go to next state
+
312  }
+
313 
+
314  break;
+
315 
+
316  case init: //Init State: Where we start the tracking
+
317  tracking_current->start(tracking_current);
+
318  state = tracking;
+
319  break;
+
320 
+
321  case tracking: //Tracking state: Where we render the frame and the tracked objects
+
322  pixy_service(); //Receive events (e.g. block-data) from pixy
+
323 
+
324  if (pixy_blocks_are_new()) { //There are new blocks available
+
325  if (frame_visible) { //If the user want's us to draw the video data
+ +
327  } else { //the user want's a colored background
+ +
329  }
+
330 
+
331 #define BLOCK_BUFFER_SIZE 5 //The maximum amount of blocks that we want to receive
+
332  struct Block blocks[BLOCK_BUFFER_SIZE]; //Storage to receive blocks from pixy
+
333  int blocks_received = pixy_get_blocks(BLOCK_BUFFER_SIZE, blocks); //Try to receive up to BLOCK_BUFFER_SIZE Blocks from pixy
+
334 
+
335  if (blocks_received >= 0) { //block receiving ok
+
336  tracking_current->update(tracking_current, blocks, blocks_received); //apply tracking
+
337 
+
338  //Draw blocks
+
339  for (int i = 0; i < blocks_received; i++) { //for each received block
+
340  struct Block* block = &(blocks[i]);
+
341  //block.x and block.y are the center coordinates of the object relative to the camera origin.
+
342  uint16_t x = block->x - 1 + FRAME_START_X - block->width / 2; //Calculate x-Coordinate on the display
+
343  uint16_t y = block->y - 1 + FRAME_START_Y - block->height / 2; //Calculate y-Coordinate on the display
+
344  tft_draw_rectangle(x, y, x + block->width - 1, y + block->height - 1, WHITE); //Draw a white rectangle
+
345  }
+
346  }
+
347  }
+
348 
+
349  break;
+
350 
+
351  case preselecting: { //Pre-Selecting State: Where we set up the color region selection
+
352  tracking_current->stop(tracking_current); //Stop tracking
+
353 
+ +
355 
+
356  touch_register_area(&a_area); //Register touch area and receive events from now on
+
357  point1_valid = false; //we start with an invalid point1
+
358 
+
359  b_select.text = "Abort"; //Change the button text to "Abort"
+
360  gui_button_redraw(&b_select); //redraw button
+
361 
+
362  state = selecting; //The user can now select a region
+
363  }
+
364  break;
+
365 
+
366  case selected: { //Selected State: Where we send the users selection to pixy
+
367  //Ensure that (x1,y1) represent the top-left point and (x2,y2) the bottom-right.
+
368  unsigned int tmp;
+
369 
+
370  if (point1.x > point2.x) {
+
371  tmp = point1.x;
+
372  point1.x = point2.x;
+
373  point2.x = tmp;
+
374  }
+
375 
+
376  if (point1.y > point2.y) {
+
377  tmp = point1.y;
+
378  point1.y = point2.y;
+
379  point2.y = tmp;
+
380  }
+
381 
+
382  //Send pixy the selected region
+
383  pixy_cc_set_region(1, point1.x, point1.y, point2.x - point1.x, point2.y - point1.y);
+
384  }
+
385 
+
386  //no break here: We want the following code to be executed as well
+
387 
+
388  case abortselecting: { //Abort-Selecting State: Where we deinitialize the stuff we used for region selection
+
389  touch_unregister_area(&a_area); //Remove the touch area. We'll no longer receive touch events
+
390 
+
391  b_select.text = "Select Color"; //Change the button text back to "Select Color"
+
392  gui_button_redraw(&b_select); //redraw button
+
393 
+
394  tracking_current->start(tracking_current); //Start tracking again
+
395  state = tracking;
+
396  }
+
397  break;
+
398 
+
399  case selecting: //Selecting State: Where we wait on the user to select a color region
+
400  pixy_service(); //receive pixy events
+
401  //wait on user to select the image area
+
402  break;
+
403 
+
404  case error: //Error State: Where we show an error message and leave the user no other choice than to click the backbutton
+
405  //wait on user to click the back button
+
406  break;
+
407  }
+
408 }
+
409 
+
410 //Declare screen callbacks
+ +
412  enter,
+
413  leave,
+
414  update
+
415 };
+
416 
+
417 
+ +
419 {
+
420  return &screen;
+
421 }
+
TOUCH_ACTION
Definition: touch.h:52
+
bool touch_register_area(TOUCH_AREA_STRUCT *area)
Definition: touch.c:181
+
const char * text
The label of the button.
Definition: button.h:61
+
void gui_button_redraw(BUTTON_STRUCT *button)
Definition: button.c:164
+
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
+
Receive an event when the pen goes down inside the region.
Definition: touch.h:54
+
static void leave(void *screen)
+
Receive an event when the pen goes up inside the region.
Definition: touch.h:55
+
bool gui_checkbox_add(CHECKBOX_STRUCT *checkbox)
Definition: checkbox.c:70
+
static TRACKING_CONFIG_STRUCT tracking_our
+
uint16_t y1
Top Left Y-Coordinate of Area.
Definition: touch.h:75
+
uint16_t y
The Y-Coordinate of the point.
Definition: touch.h:88
+ + +
#define FRAME_START_Y
+ +
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
+
void tracking_set_mode(enum Tracking_Implementation impl)
+ +
void(* TRACKING_VOID_CALLBACK)(void *tracking_config)
+
#define RGB(r, g, b)
Definition: tft.h:48
+
#define FRAME_HEIGHT
+
uint16_t x
The X-Coordinate of the point.
Definition: touch.h:87
+
void gui_checkbox_remove(CHECKBOX_STRUCT *checkbox)
Definition: checkbox.c:119
+
uint16_t x1
Top Left X-Coordinate of Area.
Definition: touch.h:74
+
uint16_t y
Definition: pixy.h:81
+
bool checked
A boolean which indicates whether or not the checkbox is currently checked.
Definition: checkbox.h:53
+ +
#define TRANSPARENT
Definition: tft.h:66
+
static TRACKING_CONFIG_STRUCT * tracking_current
+
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
+
void touch_unregister_area(TOUCH_AREA_STRUCT *area)
Definition: touch.c:195
+
Tracking_Implementation
+
void tracking_our_update(void *tracking_config, struct Block *blocks, int num_blocks)
+ +
#define HEX(h)
Definition: tft.h:60
+
int pixy_blocks_are_new()
Indicates when new block data from Pixy is received.
+ + +
uint16_t y2
Bottom Right Y-Coordinate of Area.
Definition: touch.h:77
+
static void c_frame_toggle_cb(void *checkbox, bool checked)
+
int pixy_service()
+
Pixy's internal tracking implementation.
+
static void update(void *screen)
+ +
int16_t pixy_PID_X(int16_t x, int16_t w)
Definition: pixy_control.c:67
+
void tracking_reference_stop(void *tracking_config)
+ + + +
TOUCH_CALLBACK callback
Callback which is executed when an event occurred in this Area.
Definition: touch.h:78
+
void tracking_reference_update(void *tracking_config, struct Block *blocks, int num_blocks)
+
void tracking_reference_start(void *tracking_config)
+
int pixy_command(const char *name,...)
Send a command to Pixy.
+ +
void tft_clear(uint16_t color)
Definition: tft.c:45
+
uint16_t height
Definition: pixy.h:83
+
uint16_t x2
Bottom Right X-Coordinate of Area.
Definition: touch.h:76
+
TRACKING_VOID_CALLBACK start
+ +
#define CHECKBOX_WIN_FG_COLOR
Definition: checkbox.h:82
+
void gui_button_remove(BUTTON_STRUCT *button)
Definition: button.c:184
+ +
static BUTTON_STRUCT b_select
+
#define WHITE
Definition: tft.h:53
+
static POINT_STRUCT point1
+
TRACKING_VOID_CALLBACK stop
+
POINT_STRUCT touch_get_last_point()
Definition: touch.c:211
+
void tft_fill_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:67
+
#define FRAME_END_Y
+ +
void(* TRACKING_BLOCK_CALLBACK)(void *tracking_config, struct Block *blocks, int num_blocks)
+
static TOUCH_AREA_STRUCT a_area
+
int pixy_init()
Creates a connection with Pixy and listens for Pixy messages.
+
static volatile bool frame_visible
+
uint16_t width
Definition: pixy.h:82
+
TOUCH_ACTION hookedActions
Actions to listen to.
Definition: touch.h:73
+
#define END_OUT_ARGS
Definition: pixydefs.h:89
+
int pixy_rcs_set_position(uint8_t channel, uint16_t position)
Set pixy servo axis position.
+ +
void tft_draw_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
Definition: tft.c:61
+
SCREEN_STRUCT * get_screen_tracking()
+ +
void tracking_our_stop(void *tracking_config)
+ +
static TRACKING_CONFIG_STRUCT tracking_reference
+
void tracking_our_start(void *tracking_config)
+
static SCREEN_STRUCT screen
+
static int16_t servo_y
+
static int16_t servo_x
+
static void enter(void *screen)
+ + +
#define FRAME_WIDTH
+
TRACKING_BLOCK_CALLBACK update
+
TOUCH_AREA_STRUCT base
Basic geometry of the Checkbox. You only need to set the x1, y1, x2, y2 members of this struct...
Definition: checkbox.h:51
+
#define FRAME_END_X
+
int16_t pixy_PID_Y(int16_t x, int16_t w)
Definition: pixy_control.c:44
+
static void b_select_cb(void *button)
+
static bool point1_valid
+
static enum @2 state
+
uint16_t fgcolor
The 16-bit color of the tickmark.
Definition: checkbox.h:52
+
#define FRAME_START_X
+
static BUTTON_STRUCT b_back
+
BUTTON_CALLBACK callback
Callback which is executed when the button is pressed.
Definition: button.h:58
+
static CHECKBOX_STRUCT c_frame_toggle
+
int pixy_render_full_frame(uint16_t x, uint16_t y)
Definition: pixy_frame.c:25
+
bool gui_screen_back()
Definition: screen.c:85
+ +
int pixy_cc_set_region(uint8_t signum, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
Definition: pixy_frame.c:233
+
static POINT_STRUCT point2
+
int pixy_get_blocks(uint16_t max_blocks, struct Block *blocks)
Copies up to 'max_blocks' number of Blocks to the address pointed to by 'blocks'. ...
+
CHECKBOX_CALLBACK callback
Callback which is executed when the checkbox changes state.
Definition: checkbox.h:54
+
uint8_t font
The number of the font to use.
Definition: button.h:60
+
Our own tracking PID implementation.
+
int pixy_led_set_RGB(uint8_t red, uint8_t green, uint8_t blue)
Set color of pixy LED.
+
static void b_back_cb(void *button)
+
uint16_t x
Definition: pixy.h:80
+
Definition: pixy.h:53
+ +
static void touchCB(void *touchArea, TOUCH_ACTION triggeredAction)
+
#define END_IN_ARGS
Definition: pixydefs.h:90
+
#define BLACK
Definition: tft.h:54
+
#define INT8(v)
Definition: pixydefs.h:61
+
+ + + + diff --git a/screen__tracking_8h.html b/screen__tracking_8h.html index 67df4df..21c726c 100644 --- a/screen__tracking_8h.html +++ b/screen__tracking_8h.html @@ -127,7 +127,7 @@ Functions diff --git a/screen__tracking_8h_source.html b/screen__tracking_8h_source.html index 93dd456..015fdf6 100644 --- a/screen__tracking_8h_source.html +++ b/screen__tracking_8h_source.html @@ -89,31 +89,44 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
screen_tracking.h
-Go to the documentation of this file.
1 #include "screen.h"
-
2 
-
7 
+Go to the documentation of this file.
1 /**************************************************************************************************************************************
+
2 * Project: discoverpixy
+
3 * Website: https://github.com/t-moe/discoverpixy
+
4 * Authors: Aaron Schmocker, Timo Lang
+
5 * Institution: BFH Bern University of Applied Sciences
+
6 * File: common/app/screen_tracking.h
+
7 *
+
8 * Version History:
+
9 * Date Autor Email SHA Changes
+
10 * 2015-05-16 timolang@gmail.com e46314b Added Tracking Screen and implemented "Reference Tracking" and "Color Region Selection"
+
11 *
+
12 **************************************************************************************************************************************/
13 
-
14 
- - - -
21 };
-
22 
- -
28 
- +
14 #include "screen.h"
+
15 
+
20 
+
26 
+
27 
+ + + +
34 };
35 
-
void tracking_set_mode(enum Tracking_Implementation impl)
Definition: screen_tracking.c:178
+ +
41 
+ +
48 
+
void tracking_set_mode(enum Tracking_Implementation impl)
-
Tracking_Implementation
Definition: screen_tracking.h:18
-
Pixy's internal tracking implementation.
Definition: screen_tracking.h:20
-
Definition: screen.h:34
-
SCREEN_STRUCT * get_screen_tracking()
Definition: screen_tracking.c:378
-
Our own tracking PID implementation.
Definition: screen_tracking.h:19
+
Tracking_Implementation
+
Pixy's internal tracking implementation.
+ +
SCREEN_STRUCT * get_screen_tracking()
+
Our own tracking PID implementation.
diff --git a/struct_b_u_t_t_o_n___s_t_r_u_c_t.html b/struct_b_u_t_t_o_n___s_t_r_u_c_t.html index 164f987..438b5b5 100644 --- a/struct_b_u_t_t_o_n___s_t_r_u_c_t.html +++ b/struct_b_u_t_t_o_n___s_t_r_u_c_t.html @@ -121,6 +121,8 @@ Data Fields

Detailed Description

Structure to configure the Button

+ +

Definition at line 55 of file button.h.

Field Documentation

@@ -134,6 +136,8 @@ Data Fields

Basic geometry of the button. You only need to set the x1, y1, x2, y2 members of this struct.

+

Definition at line 56 of file button.h.

+
@@ -148,6 +152,8 @@ Data Fields

The 16-bit background color of the button.

+

Definition at line 57 of file button.h.

+ @@ -162,6 +168,8 @@ Data Fields

Callback which is executed when the button is pressed.

+

Definition at line 58 of file button.h.

+ @@ -176,6 +184,8 @@ Data Fields

The number of the font to use.

+

Definition at line 60 of file button.h.

+ @@ -190,6 +200,8 @@ Data Fields

The label of the button.

+

Definition at line 61 of file button.h.

+ @@ -204,6 +216,8 @@ Data Fields

The 16-bit text color.

+

Definition at line 59 of file button.h.

+
The documentation for this struct was generated from the following file: