Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc18c175b5 | ||
|
|
cafa320e9e | ||
|
|
c32bfde94e | ||
|
|
129b7e0ee7 | ||
|
|
0fa18290dd |
8
Doxyfile
8
Doxyfile
@@ -959,13 +959,13 @@ USE_MDFILE_AS_MAINPAGE =
|
|||||||
# also VERBATIM_HEADERS is set to NO.
|
# also VERBATIM_HEADERS is set to NO.
|
||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
|
|
||||||
SOURCE_BROWSER = YES
|
SOURCE_BROWSER = NO
|
||||||
|
|
||||||
# Setting the INLINE_SOURCES tag to YES will include the body of functions,
|
# Setting the INLINE_SOURCES tag to YES will include the body of functions,
|
||||||
# classes and enums directly into the documentation.
|
# classes and enums directly into the documentation.
|
||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
|
|
||||||
INLINE_SOURCES = YES
|
INLINE_SOURCES = NO
|
||||||
|
|
||||||
# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any
|
# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any
|
||||||
# special comment blocks from generated source code fragments. Normal C, C++ and
|
# special comment blocks from generated source code fragments. Normal C, C++ and
|
||||||
@@ -1610,7 +1610,7 @@ EXTRA_SEARCH_MAPPINGS =
|
|||||||
# If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output.
|
# If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output.
|
||||||
# The default value is: YES.
|
# The default value is: YES.
|
||||||
|
|
||||||
GENERATE_LATEX = YES
|
GENERATE_LATEX = NO
|
||||||
|
|
||||||
# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a
|
# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a
|
||||||
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
|
# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
|
||||||
@@ -1751,7 +1751,7 @@ LATEX_HIDE_INDICES = NO
|
|||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
# This tag requires that the tag GENERATE_LATEX is set to YES.
|
# This tag requires that the tag GENERATE_LATEX is set to YES.
|
||||||
|
|
||||||
LATEX_SOURCE_CODE = YES
|
LATEX_SOURCE_CODE = NO
|
||||||
|
|
||||||
# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
|
# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
|
||||||
# bibliography, e.g. plainnat, or ieeetr. See
|
# bibliography, e.g. plainnat, or ieeetr. See
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ A Project with the Pixy cam and the STM32F4 Discovery. The project can also be r
|
|||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
Take a look at our [docu.pdf](./doc/docu.pdf) (German)
|
Take a look at our [docu.pdf](./doc/docu.pdf) (German)
|
||||||
Also make sure to check out the [doxygen documentation](http://t-moe.github.io/discoverpixy/) for the common folder.
|
|
||||||
|
|
||||||
|
|
||||||
## Folder structure
|
## Folder structure
|
||||||
* *common*: device independent code and the "Application" itself
|
* *common*: device independent code and the "Application" itself
|
||||||
|
|||||||
@@ -1,32 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/app/app.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-03 timolang@gmail.com 51089aa Refactored Project Structure for use with emulator
|
|
||||||
* 2015-04-03 timolang@gmail.com 1f2af9f Added more tft functions to common and emulator. Fixed eventloop.
|
|
||||||
* 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
|
|
||||||
* 2015-04-03 timolang@gmail.com 1aa9194 Fixed Drawing of rects in Emulator. Got frames from pixy to emulator. Slooooow.
|
|
||||||
* 2015-04-25 timolang@gmail.com 416883c Pixy&Usb work with the new folder structure now.
|
|
||||||
* 2015-04-25 timolang@gmail.com 3d1e4b2 Simplified code a bit. Emulator does not work stable when replugging pixy.
|
|
||||||
* 2015-04-25 timolang@gmail.com 0858b0d Fixed some bugs when receiving large data.
|
|
||||||
* 2015-04-27 timolang@gmail.com 259d446 Added touch support to emulator. Implemented basic touch function.
|
|
||||||
* 2015-04-27 aaron@duckpond.ch aed90ef Drawcircle added (emulator)
|
|
||||||
* 2015-04-27 timolang@gmail.com e249fb2 Added font support
|
|
||||||
* 2015-04-27 timolang@gmail.com 7c9eabc Added button support.
|
|
||||||
* 2015-04-27 timolang@gmail.com b300ac5 Added Checkbox support
|
|
||||||
* 2015-04-27 timolang@gmail.com cf72baa Introduced a Screen (sub) module and divided app into multiple screens.
|
|
||||||
* 2015-05-10 timolang@gmail.com e2bce8f Added filesystem module, tests and implementation for it in emulator.
|
|
||||||
* 2015-05-12 aaron@duckpond.ch aec62d4 Added datasheets, updated touchsupport.
|
|
||||||
* 2015-05-28 aaron@duckpond.ch 5bda699 implemented functions to get x and y coordinates and a test function
|
|
||||||
* 2015-05-29 aaron@duckpond.ch 7d2d1a1 Implemented basic sampling and averaging of touch coordinates using timer7
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include "tft.h"
|
#include "tft.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
@@ -34,8 +5,7 @@
|
|||||||
#include "screen_main.h"
|
#include "screen_main.h"
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
|
|
||||||
void app_init()
|
void app_init() {
|
||||||
{
|
|
||||||
system_init();
|
system_init();
|
||||||
tft_init();
|
tft_init();
|
||||||
touch_init();
|
touch_init();
|
||||||
@@ -45,9 +15,10 @@ void app_init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//app event loop
|
//app event loop
|
||||||
void app_process()
|
void app_process() {
|
||||||
{
|
|
||||||
|
|
||||||
system_process(); //Let the system handle it's pending events
|
system_process(); //Let the system handle it's pending events
|
||||||
gui_screen_update(); //update the currently active screen
|
gui_screen_update(); //update the currently active screen
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +1,6 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/app/app.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-03 timolang@gmail.com 51089aa Refactored Project Structure for use with emulator
|
|
||||||
* 2015-05-10 timolang@gmail.com 21edc56 Added doxyfile (doxygen) for the common folder. Started with doxygen comments for app and tft module.
|
|
||||||
* 2015-05-11 timolang@gmail.com 08d9fe0 More work on doxygen module structure
|
|
||||||
* 2015-06-08 timolang@gmail.com 73db8b5 Added doxygen mainpage comment in app.h
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#ifndef APP_H
|
#ifndef APP_H
|
||||||
#define APP_H
|
#define APP_H
|
||||||
|
|
||||||
/*!
|
|
||||||
\mainpage discoverpixy Doxygen Documentation
|
|
||||||
Welcome to the code-documentation for all common (and plattformindependent) code. \n
|
|
||||||
A good point to start is probably the <a href="modules.html">Modules</a> page.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup app Application
|
* @defgroup app Application
|
||||||
* The App Module contains the effective, platform independent application.
|
* The App Module contains the effective, platform independent application.
|
||||||
|
|||||||
@@ -1,21 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/app/pixy_control.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-06-02 aaron@duckpond.ch e018a75 Implemented basic pi and pid controller
|
|
||||||
* 2015-06-06 aaron@duckpond.ch 8c264c2 Comment refactoring, updated PID values
|
|
||||||
* 2015-06-06 aaron@duckpond.ch a04cda9 Refactured comments and implemented a bugfix for the PID controller
|
|
||||||
* 2015-06-07 aaron@duckpond.ch 802d3df Fixed pid controller and refactored code
|
|
||||||
* 2015-06-07 aaron@duckpond.ch 3d98ca9 Minor changes
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* pixy_control.c
|
* pixy_control.c
|
||||||
*
|
*
|
||||||
@@ -34,11 +16,10 @@
|
|||||||
#include<stdint.h>
|
#include<stdint.h>
|
||||||
|
|
||||||
// PID tuning factors
|
// PID tuning factors
|
||||||
#define REG_PID_KP (0.41f)
|
#define REG_PID_KP (0.5f)
|
||||||
#define REG_PID_KI (0.001f)
|
#define REG_PID_KI (0.001f)
|
||||||
#define REG_PID_KD (0.00025f)
|
#define REG_PID_KD (0.001f)
|
||||||
#define REG_PID_TA (0.001f)
|
#define REG_PID_TA (0.01f)
|
||||||
#define REG_PID_YKOR (0.3f)
|
|
||||||
|
|
||||||
|
|
||||||
// PID controller implementatoin for the y-axis
|
// PID controller implementatoin for the y-axis
|
||||||
@@ -54,7 +35,7 @@ int16_t pixy_PID_Y(int16_t x, int16_t w)
|
|||||||
//----PID-control-------------------------------------------------------------------------
|
//----PID-control-------------------------------------------------------------------------
|
||||||
esum = esum + e; // add e to the current sum
|
esum = esum + e; // add e to the current sum
|
||||||
|
|
||||||
y += (REG_PID_KP + REG_PID_YKOR) * e; // add the proportional part to the output
|
y += REG_PID_KP * e; // add the proportional part to the output
|
||||||
y += REG_PID_KI * REG_PID_TA * esum; // add the integral part to the output
|
y += REG_PID_KI * REG_PID_TA * esum; // add the integral part to the output
|
||||||
y += REG_PID_KD * (e - eold) / REG_PID_TA; // add the differential part to the output
|
y += REG_PID_KD * (e - eold) / REG_PID_TA; // add the differential part to the output
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -1,20 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/app/pixy_control.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-06-02 aaron@duckpond.ch e018a75 Implemented basic pi and pid controller
|
|
||||||
* 2015-06-06 aaron@duckpond.ch 8c264c2 Comment refactoring, updated PID values
|
|
||||||
* 2015-06-06 aaron@duckpond.ch a04cda9 Refactured comments and implemented a bugfix for the PID controller
|
|
||||||
* 2015-06-07 aaron@duckpond.ch 802d3df Fixed pid controller and refactored code
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#ifndef PIXY_CONTROL_H_
|
#ifndef PIXY_CONTROL_H_
|
||||||
#define PIXY_CONTROL_H_
|
#define PIXY_CONTROL_H_
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/app/pixy_frame.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "pixy_frame.h"
|
#include "pixy_frame.h"
|
||||||
#include "pixy.h"
|
#include "pixy.h"
|
||||||
#include "tft.h"
|
#include "tft.h"
|
||||||
@@ -22,14 +9,12 @@ static int renderBA81(uint16_t xpos, uint16_t ypos, uint16_t width, uint16_t hei
|
|||||||
static int saveBA81(FILE_HANDLE* handle, uint16_t width, uint16_t height, uint32_t frameLen, uint8_t *frame);
|
static int saveBA81(FILE_HANDLE* handle, uint16_t width, uint16_t height, uint32_t frameLen, uint8_t *frame);
|
||||||
|
|
||||||
|
|
||||||
int pixy_render_full_frame(uint16_t x, uint16_t y)
|
int pixy_render_full_frame(uint16_t x, uint16_t y) {
|
||||||
{
|
|
||||||
return pixy_render_cropped_frame(x,y,0,0,320,200);
|
return pixy_render_cropped_frame(x,y,0,0,320,200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int pixy_render_cropped_frame(uint16_t x, uint16_t y, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
|
int pixy_render_cropped_frame(uint16_t x, uint16_t y, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height) {
|
||||||
{
|
|
||||||
uint8_t* videodata;
|
uint8_t* videodata;
|
||||||
int32_t response;
|
int32_t response;
|
||||||
int32_t fourccc;
|
int32_t fourccc;
|
||||||
@@ -62,13 +47,11 @@ int pixy_render_cropped_frame(uint16_t x, uint16_t y, uint16_t xoffset, uint16_t
|
|||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pixy_save_full_frame(FILE_HANDLE* handle)
|
int pixy_save_full_frame(FILE_HANDLE* handle) {
|
||||||
{
|
|
||||||
return pixy_save_cropped_frame(handle,0,0,320,200);
|
return pixy_save_cropped_frame(handle,0,0,320,200);
|
||||||
}
|
}
|
||||||
|
|
||||||
int pixy_save_cropped_frame(FILE_HANDLE* handle, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
|
int pixy_save_cropped_frame(FILE_HANDLE* handle, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height) {
|
||||||
{
|
|
||||||
uint8_t* videodata;
|
uint8_t* videodata;
|
||||||
int32_t response;
|
int32_t response;
|
||||||
int32_t fourccc;
|
int32_t fourccc;
|
||||||
@@ -107,22 +90,31 @@ int pixy_save_cropped_frame(FILE_HANDLE* handle, uint16_t xoffset, uint16_t yoff
|
|||||||
|
|
||||||
static void interpolateBayer(uint16_t width, uint16_t x, uint16_t y, uint8_t *pixel, uint8_t* r, uint8_t* g, uint8_t* b)
|
static void interpolateBayer(uint16_t width, uint16_t x, uint16_t y, uint8_t *pixel, uint8_t* r, uint8_t* g, uint8_t* b)
|
||||||
{
|
{
|
||||||
if (y & 1) {
|
if (y&1)
|
||||||
if (x & 1) {
|
{
|
||||||
|
if (x&1)
|
||||||
|
{
|
||||||
*r = *pixel;
|
*r = *pixel;
|
||||||
*g = (*(pixel-1)+*(pixel+1)+*(pixel+width)+*(pixel-width))>>2;
|
*g = (*(pixel-1)+*(pixel+1)+*(pixel+width)+*(pixel-width))>>2;
|
||||||
*b = (*(pixel-width-1)+*(pixel-width+1)+*(pixel+width-1)+*(pixel+width+1))>>2;
|
*b = (*(pixel-width-1)+*(pixel-width+1)+*(pixel+width-1)+*(pixel+width+1))>>2;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
*r = (*(pixel-1)+*(pixel+1))>>1;
|
*r = (*(pixel-1)+*(pixel+1))>>1;
|
||||||
*g = *pixel;
|
*g = *pixel;
|
||||||
*b = (*(pixel-width)+*(pixel+width))>>1;
|
*b = (*(pixel-width)+*(pixel+width))>>1;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
if (x & 1) {
|
else
|
||||||
|
{
|
||||||
|
if (x&1)
|
||||||
|
{
|
||||||
*r = (*(pixel-width)+*(pixel+width))>>1;
|
*r = (*(pixel-width)+*(pixel+width))>>1;
|
||||||
*g = *pixel;
|
*g = *pixel;
|
||||||
*b = (*(pixel-1)+*(pixel+1))>>1;
|
*b = (*(pixel-1)+*(pixel+1))>>1;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
*r = (*(pixel-width-1)+*(pixel-width+1)+*(pixel+width-1)+*(pixel+width+1))>>2;
|
*r = (*(pixel-width-1)+*(pixel-width+1)+*(pixel+width-1)+*(pixel+width+1))>>2;
|
||||||
*g = (*(pixel-1)+*(pixel+1)+*(pixel+width)+*(pixel-width))>>2;
|
*g = (*(pixel-1)+*(pixel+1)+*(pixel+width)+*(pixel-width))>>2;
|
||||||
*b = *pixel;
|
*b = *pixel;
|
||||||
@@ -152,29 +144,28 @@ static int renderBA81(uint16_t xpos, uint16_t ypos, uint16_t width, uint16_t hei
|
|||||||
|
|
||||||
if(decodedimage==NULL) { //not enough free space to decode image in memory
|
if(decodedimage==NULL) { //not enough free space to decode image in memory
|
||||||
//decode & render image pixel by pixel
|
//decode & render image pixel by pixel
|
||||||
for (y = 1; y < height - 1; y++) {
|
for (y=1; y<height-1; y++)
|
||||||
|
{
|
||||||
frame++;
|
frame++;
|
||||||
|
for (x=1; x<width-1; x++, frame++)
|
||||||
for (x = 1; x < width - 1; x++, frame++) {
|
{
|
||||||
interpolateBayer(width, x, y, frame, &r, &g, &b);
|
interpolateBayer(width, x, y, frame, &r, &g, &b);
|
||||||
tft_draw_pixel(xpos+x-1,ypos+y-1,RGB(r,g,b));
|
tft_draw_pixel(xpos+x-1,ypos+y-1,RGB(r,g,b));
|
||||||
}
|
}
|
||||||
|
|
||||||
frame++;
|
frame++;
|
||||||
}
|
}
|
||||||
} else { //enough space
|
} else { //enough space
|
||||||
uint16_t* line = decodedimage;
|
uint16_t* line = decodedimage;
|
||||||
|
for (y=1; y<height-1; y++)
|
||||||
for (y = 1; y < height - 1; y++) {
|
{
|
||||||
//line = (unsigned int *)img.scanLine(y-1);
|
//line = (unsigned int *)img.scanLine(y-1);
|
||||||
frame++;
|
frame++;
|
||||||
|
for (x=1; x<width-1; x++, frame++)
|
||||||
for (x = 1; x < width - 1; x++, frame++) {
|
{
|
||||||
interpolateBayer(width, x, y, frame, &r, &g, &b);
|
interpolateBayer(width, x, y, frame, &r, &g, &b);
|
||||||
//*line++ = (0xff<<24) | (r<<16) | (g<<8) | (b<<0);
|
//*line++ = (0xff<<24) | (r<<16) | (g<<8) | (b<<0);
|
||||||
*line++ = RGB(r,g,b);
|
*line++ = RGB(r,g,b);
|
||||||
}
|
}
|
||||||
|
|
||||||
frame++;
|
frame++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,7 +193,8 @@ static int saveBA81(FILE_HANDLE* handle, uint16_t width, uint16_t height, uint32
|
|||||||
// don't render top and bottom rows, and left and rightmost columns because of color
|
// don't render top and bottom rows, and left and rightmost columns because of color
|
||||||
// interpolation
|
// interpolation
|
||||||
|
|
||||||
for (y = 1; y < height - 1; y++) {
|
for (y=1; y<height-1; y++)
|
||||||
|
{
|
||||||
frame++;
|
frame++;
|
||||||
uint8_t rowbuf[row_size_padded];
|
uint8_t rowbuf[row_size_padded];
|
||||||
|
|
||||||
@@ -211,7 +203,8 @@ static int saveBA81(FILE_HANDLE* handle, uint16_t width, uint16_t height, uint32
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (x = 1; x < width - 1; x++, frame++) {
|
for (x=1; x<width-1; x++, frame++)
|
||||||
|
{
|
||||||
interpolateBayer(width, x, y, frame, &r, &g, &b);
|
interpolateBayer(width, x, y, frame, &r, &g, &b);
|
||||||
//bitmaps are saved in 24bit b,g,r format
|
//bitmaps are saved in 24bit b,g,r format
|
||||||
rowbuf[(x-1)*3] = b;
|
rowbuf[(x-1)*3] = b;
|
||||||
@@ -225,13 +218,11 @@ static int saveBA81(FILE_HANDLE* handle, uint16_t width, uint16_t height, uint32
|
|||||||
|
|
||||||
frame++;
|
frame++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int pixy_cc_set_region(uint8_t signum, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height)
|
int pixy_cc_set_region(uint8_t signum, uint16_t xoffset, uint16_t yoffset, uint16_t width, uint16_t height) {
|
||||||
{
|
|
||||||
int32_t response;
|
int32_t response;
|
||||||
|
|
||||||
int return_value = pixy_command("cc_setSigRegion", // String id for remote procedure
|
int return_value = pixy_command("cc_setSigRegion", // String id for remote procedure
|
||||||
@@ -246,3 +237,5 @@ int pixy_cc_set_region(uint8_t signum, uint16_t xoffset, uint16_t yoffset, uint1
|
|||||||
END_IN_ARGS);
|
END_IN_ARGS);
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/app/pixy_frame.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#ifndef PIXY_FRAME_H
|
#ifndef PIXY_FRAME_H
|
||||||
#define PIXY_FRAME_H
|
#define PIXY_FRAME_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/app/screen_filetest.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-05-10 timolang@gmail.com e2bce8f Added filesystem module, tests and implementation for it in emulator.
|
|
||||||
* 2015-05-10 timolang@gmail.com 790f602 Added bitmap decoding/drawing example
|
|
||||||
* 2015-05-10 timolang@gmail.com 21edc56 Added doxyfile (doxygen) for the common folder. Started with doxygen comments for app and tft module.
|
|
||||||
* 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.
|
|
||||||
* 2015-05-15 timolang@gmail.com 85f1aee Changed filetest to use new bitmap draw method.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "screen_filetest.h"
|
#include "screen_filetest.h"
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
#include "tft.h"
|
#include "tft.h"
|
||||||
@@ -24,16 +7,14 @@
|
|||||||
|
|
||||||
static BUTTON_STRUCT b_back;
|
static BUTTON_STRUCT b_back;
|
||||||
|
|
||||||
static void b_back_cb(void* button)
|
static void b_back_cb(void* button) {
|
||||||
{
|
|
||||||
gui_screen_back();
|
gui_screen_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void image_test();
|
static void image_test();
|
||||||
|
|
||||||
static void enter(void* screen)
|
static void enter(void* screen) {
|
||||||
{
|
|
||||||
tft_clear(HEX(0xBABECD));
|
tft_clear(HEX(0xBABECD));
|
||||||
|
|
||||||
//Back button
|
//Back button
|
||||||
@@ -48,16 +29,27 @@ static void enter(void* screen)
|
|||||||
b_back.callback=b_back_cb; //Call b_back_cb as Callback
|
b_back.callback=b_back_cb; //Call b_back_cb as Callback
|
||||||
gui_button_add(&b_back); //Register Button (and run the callback from now on)
|
gui_button_add(&b_back); //Register Button (and run the callback from now on)
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
//tft test
|
||||||
|
tft_draw_pixel(0,0,BLACK);
|
||||||
|
tft_draw_pixel(319,239,BLACK);
|
||||||
|
tft_draw_pixel(10,210,BLUE);
|
||||||
|
tft_draw_pixel(12,210,BLUE);
|
||||||
|
tft_draw_rectangle(40,100,60,235,BLUE);
|
||||||
|
tft_fill_rectangle(100,215,200,225,GREEN);
|
||||||
|
tft_draw_line(10,50,310,225,RGB(0xFF,0,0xFF));
|
||||||
|
tft_draw_circle(10,10,100, RED);
|
||||||
|
tft_print_line(30, 130, RED, BLUE, 0, "Hallo");
|
||||||
|
*/
|
||||||
|
|
||||||
tft_draw_line(10,30,310,30,BLACK);
|
tft_draw_line(10,30,310,30,BLACK);
|
||||||
tft_print_line(10,18,BLUE,TRANSPARENT,0,"Name D H RO Date Time Size");
|
tft_print_line(10,18,BLUE,TRANSPARENT,0,"Name D H RO Date Time Size");
|
||||||
|
|
||||||
int y = 33;
|
int y = 33;
|
||||||
|
|
||||||
DIRECTORY_STRUCT* dir = filesystem_dir_open(".");
|
DIRECTORY_STRUCT* dir = filesystem_dir_open(".");
|
||||||
|
if(dir==NULL) return;
|
||||||
if (dir == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i=0; i<dir->num_files; i++) {
|
for(int i=0; i<dir->num_files; i++) {
|
||||||
FILE_STRUCT* file = &(dir->files[i]);
|
FILE_STRUCT* file = &(dir->files[i]);
|
||||||
@@ -83,7 +75,6 @@ static void enter(void* screen)
|
|||||||
y+=14;
|
y+=14;
|
||||||
|
|
||||||
FILE_HANDLE* file = filesystem_file_open("test.txt");
|
FILE_HANDLE* file = filesystem_file_open("test.txt");
|
||||||
|
|
||||||
if(file==NULL) {
|
if(file==NULL) {
|
||||||
tft_print_line(10,y,BLUE,TRANSPARENT,0,"Could not open test.txt");
|
tft_print_line(10,y,BLUE,TRANSPARENT,0,"Could not open test.txt");
|
||||||
} else {
|
} else {
|
||||||
@@ -103,7 +94,6 @@ static void enter(void* screen)
|
|||||||
tft_print_formatted(10,y,BLUE,TRANSPARENT,0,"Could not seek to %d",file->fpos-4);
|
tft_print_formatted(10,y,BLUE,TRANSPARENT,0,"Could not seek to %d",file->fpos-4);
|
||||||
} else {
|
} else {
|
||||||
sprintf(buf,"%04d",num);
|
sprintf(buf,"%04d",num);
|
||||||
|
|
||||||
if(filesystem_file_write(file,buf,4) != F_OK) {
|
if(filesystem_file_write(file,buf,4) != F_OK) {
|
||||||
tft_print_formatted(10,y,BLUE,TRANSPARENT,0,"Could not write new number %d",num);
|
tft_print_formatted(10,y,BLUE,TRANSPARENT,0,"Could not write new number %d",num);
|
||||||
} else {
|
} else {
|
||||||
@@ -115,19 +105,16 @@ static void enter(void* screen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
filesystem_file_close(file);
|
filesystem_file_close(file);
|
||||||
|
|
||||||
image_test();
|
image_test();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void leave(void* screen)
|
static void leave(void* screen) {
|
||||||
{
|
|
||||||
gui_button_remove(&b_back);
|
gui_button_remove(&b_back);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update(void* screen)
|
static void update(void* screen) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -138,18 +125,15 @@ static SCREEN_STRUCT screen = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
SCREEN_STRUCT* get_screen_filetest()
|
SCREEN_STRUCT* get_screen_filetest() {
|
||||||
{
|
|
||||||
return &screen;
|
return &screen;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void image_test()
|
static void image_test() {
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
if(!tft_draw_bitmap_file_unscaled(250,170,"cpu.bmp")) {
|
if(!tft_draw_bitmap_file_unscaled(250,170,"cpu.bmp")) {
|
||||||
tft_print_line(10,180,BLUE,TRANSPARENT,0,"Could not open cpu.bmp");
|
tft_print_line(10,180,BLUE,TRANSPARENT,0,"Could not open cpu.bmp");
|
||||||
}
|
}
|
||||||
|
|
||||||
tft_draw_rectangle(250-1,170-1,250-1+64,170-1+64,BLACK);
|
tft_draw_rectangle(250-1,170-1,250-1+64,170-1+64,BLACK);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/app/screen_filetest.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-05-10 timolang@gmail.com e2bce8f Added filesystem module, tests and implementation for it in emulator.
|
|
||||||
* 2015-05-10 timolang@gmail.com 21edc56 Added doxyfile (doxygen) for the common folder. Started with doxygen comments for app and tft module.
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,21 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/app/screen_guitest.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-27 timolang@gmail.com cf72baa Introduced a Screen (sub) module and divided app into multiple screens.
|
|
||||||
* 2015-04-30 timolang@gmail.com 76ea9d8 Added num up down support.
|
|
||||||
* 2015-05-09 timolang@gmail.com c652b6b Improved Emulator Gui
|
|
||||||
* 2015-05-29 aaron@duckpond.ch 7d2d1a1 Implemented basic sampling and averaging of touch coordinates using timer7
|
|
||||||
* 2015-06-01 timolang@gmail.com eb573bc Finalized calibration. Fixed a bug in screen module.
|
|
||||||
* 2015-06-02 timolang@gmail.com da34bce Fixed all printf related problems on discovery using workarounds and newlib nano-instead of newlib
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "screen_guitest.h"
|
#include "screen_guitest.h"
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
#include "tft.h"
|
#include "tft.h"
|
||||||
@@ -27,53 +9,43 @@ static TOUCH_AREA_STRUCT a_area;
|
|||||||
static CHECKBOX_STRUCT c_cbox;
|
static CHECKBOX_STRUCT c_cbox;
|
||||||
static NUMUPDOWN_STRUCT n_updown;
|
static NUMUPDOWN_STRUCT n_updown;
|
||||||
|
|
||||||
static void checkboxCB(void* checkbox, bool checked)
|
static void checkboxCB(void *checkbox, bool checked) {
|
||||||
{
|
|
||||||
printf("Checkbox %s\n",(checked?"checked":"unchecked"));
|
printf("Checkbox %s\n",(checked?"checked":"unchecked"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void b_back_cb(void* button)
|
static void b_back_cb(void* button) {
|
||||||
{
|
|
||||||
gui_screen_back();
|
gui_screen_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void n_updown_cb(void* numupdown, int16_t value)
|
static void n_updown_cb(void* numupdown, int16_t value) {
|
||||||
{
|
|
||||||
printf("New NumUpDown Value %d\n",value);
|
printf("New NumUpDown Value %d\n",value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void touchCB(void* touchArea, TOUCH_ACTION triggeredAction)
|
static void touchCB(void* touchArea, TOUCH_ACTION triggeredAction) {
|
||||||
{
|
|
||||||
|
|
||||||
switch(triggeredAction) {
|
switch(triggeredAction) {
|
||||||
case PEN_DOWN:
|
case PEN_DOWN:
|
||||||
printf("action PEN_DOWN\n");
|
printf("action PEN_DOWN\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PEN_UP:
|
case PEN_UP:
|
||||||
printf("action PEN_UP\n");
|
printf("action PEN_UP\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PEN_MOVE:
|
case PEN_MOVE:
|
||||||
printf("action PEN_MOVE\n");
|
printf("action PEN_MOVE\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PEN_ENTER:
|
case PEN_ENTER:
|
||||||
printf("action PEN_ENTER\n");
|
printf("action PEN_ENTER\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PEN_LEAVE:
|
case PEN_LEAVE:
|
||||||
printf("action PEN_LEAVE\n");
|
printf("action PEN_LEAVE\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf("action %s\n",triggeredAction);
|
printf("action %s\n",triggeredAction);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void enter(void* screen)
|
static void enter(void* screen) {
|
||||||
{
|
|
||||||
tft_clear(HEX(0xA6FD9A));
|
tft_clear(HEX(0xA6FD9A));
|
||||||
|
|
||||||
//Back button
|
//Back button
|
||||||
@@ -136,16 +108,14 @@ static void enter(void* screen)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void leave(void* screen)
|
static void leave(void* screen) {
|
||||||
{
|
|
||||||
gui_button_remove(&b_back);
|
gui_button_remove(&b_back);
|
||||||
gui_checkbox_remove(&c_cbox);
|
gui_checkbox_remove(&c_cbox);
|
||||||
gui_numupdown_remove(&n_updown);
|
gui_numupdown_remove(&n_updown);
|
||||||
touch_unregister_area(&a_area);
|
touch_unregister_area(&a_area);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update(void* screen)
|
static void update(void* screen) {
|
||||||
{
|
|
||||||
//gui_button_redraw(&b_back); //only needed if button is overdrawn by others
|
//gui_button_redraw(&b_back); //only needed if button is overdrawn by others
|
||||||
//.... for the other elements as well
|
//.... for the other elements as well
|
||||||
}
|
}
|
||||||
@@ -158,7 +128,8 @@ static SCREEN_STRUCT screen = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
SCREEN_STRUCT* get_screen_guitest()
|
SCREEN_STRUCT* get_screen_guitest() {
|
||||||
{
|
|
||||||
return &screen;
|
return &screen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/app/screen_guitest.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-27 timolang@gmail.com cf72baa Introduced a Screen (sub) module and divided app into multiple screens.
|
|
||||||
* 2015-05-10 timolang@gmail.com 21edc56 Added doxyfile (doxygen) for the common folder. Started with doxygen comments for app and tft module.
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/app/screen_main.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-27 timolang@gmail.com cf72baa Introduced a Screen (sub) module and divided app into multiple screens.
|
|
||||||
* 2015-05-10 timolang@gmail.com e2bce8f Added filesystem module, tests and implementation for it in emulator.
|
|
||||||
* 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.
|
|
||||||
* 2015-05-16 timolang@gmail.com e46314b Added Tracking Screen and implemented "Reference Tracking" and "Color Region Selection"
|
|
||||||
* 2015-06-01 aaron@duckpond.ch caa7b5c Added IRQ for user button, fixed some touchproblems.
|
|
||||||
* 2015-06-01 timolang@gmail.com 3155f42 Fixed mainscreen layout.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "screen_main.h"
|
#include "screen_main.h"
|
||||||
#include "screen_guitest.h"
|
#include "screen_guitest.h"
|
||||||
#include "screen_pixytest.h"
|
#include "screen_pixytest.h"
|
||||||
@@ -35,41 +17,34 @@ BUTTON_STRUCT b_ref_tracking;
|
|||||||
BUTTON_STRUCT b_photo_mode;
|
BUTTON_STRUCT b_photo_mode;
|
||||||
|
|
||||||
|
|
||||||
static void b_our_tracking_cb(void* button)
|
static void b_our_tracking_cb(void* button) {
|
||||||
{
|
|
||||||
tracking_set_mode(OUR_TRACKING);
|
tracking_set_mode(OUR_TRACKING);
|
||||||
gui_screen_navigate(get_screen_tracking());
|
gui_screen_navigate(get_screen_tracking());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void b_ref_tracking_cb(void* button)
|
static void b_ref_tracking_cb(void* button) {
|
||||||
{
|
|
||||||
tracking_set_mode(REFERENCE_TRACKING);
|
tracking_set_mode(REFERENCE_TRACKING);
|
||||||
gui_screen_navigate(get_screen_tracking());
|
gui_screen_navigate(get_screen_tracking());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void b_photo_mode_cb(void* button)
|
static void b_photo_mode_cb(void* button) {
|
||||||
{
|
|
||||||
gui_screen_navigate(get_screen_photomode());
|
gui_screen_navigate(get_screen_photomode());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void b_guitest_cb(void* button)
|
static void b_guitest_cb(void* button) {
|
||||||
{
|
|
||||||
gui_screen_navigate(get_screen_guitest());
|
gui_screen_navigate(get_screen_guitest());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void b_filetest_cb(void* button)
|
static void b_filetest_cb(void* button) {
|
||||||
{
|
|
||||||
gui_screen_navigate(get_screen_filetest());
|
gui_screen_navigate(get_screen_filetest());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void b_pixytest_cb(void* button)
|
static void b_pixytest_cb(void* button) {
|
||||||
{
|
|
||||||
gui_screen_navigate(get_screen_pixytest());
|
gui_screen_navigate(get_screen_pixytest());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void enter(void* screen)
|
static void enter(void* screen) {
|
||||||
{
|
|
||||||
tft_clear(WHITE);
|
tft_clear(WHITE);
|
||||||
|
|
||||||
//Heading
|
//Heading
|
||||||
@@ -170,8 +145,7 @@ static void enter(void* screen)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void leave(void* screen)
|
static void leave(void* screen) {
|
||||||
{
|
|
||||||
gui_button_remove(&b_our_tracking);
|
gui_button_remove(&b_our_tracking);
|
||||||
gui_button_remove(&b_ref_tracking);
|
gui_button_remove(&b_ref_tracking);
|
||||||
gui_button_remove(&b_photo_mode);
|
gui_button_remove(&b_photo_mode);
|
||||||
@@ -180,8 +154,7 @@ static void leave(void* screen)
|
|||||||
gui_button_remove(&b_filetest);
|
gui_button_remove(&b_filetest);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update(void* screen)
|
static void update(void* screen) {
|
||||||
{
|
|
||||||
//gui_button_redraw(&b_guitest); //only needed if button is overdrawn by others
|
//gui_button_redraw(&b_guitest); //only needed if button is overdrawn by others
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,7 +166,8 @@ static SCREEN_STRUCT screen = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
SCREEN_STRUCT* get_screen_main()
|
SCREEN_STRUCT* get_screen_main() {
|
||||||
{
|
|
||||||
return &screen;
|
return &screen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/app/screen_main.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-27 timolang@gmail.com cf72baa Introduced a Screen (sub) module and divided app into multiple screens.
|
|
||||||
* 2015-05-10 timolang@gmail.com 21edc56 Added doxyfile (doxygen) for the common folder. Started with doxygen comments for app and tft module.
|
|
||||||
* 2015-05-11 timolang@gmail.com 08d9fe0 More work on doxygen module structure
|
|
||||||
* 2015-05-12 timolang@gmail.com 1402598 Added doxygen stuff for button module and some minor changes to touch, screen_main and tft module.
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,18 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/app/screen_photomode.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 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.
|
|
||||||
* 2015-05-16 timolang@gmail.com 62006e0 Documented pixy_helper and implemented/finished photo-mode screens! Snap some shots!
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "screen_photomode.h"
|
#include "screen_photomode.h"
|
||||||
#include "screen_photomode_save.h"
|
#include "screen_photomode_save.h"
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
@@ -30,15 +15,13 @@ static TOUCH_AREA_STRUCT a_area; //Touch Area, where the frame is drawn. Used to
|
|||||||
static bool subMenu=false; //Whether or not we left the current screen for a submenu
|
static bool subMenu=false; //Whether or not we left the current screen for a submenu
|
||||||
|
|
||||||
//Callback for when the user presses the "back" button
|
//Callback for when the user presses the "back" button
|
||||||
static void b_back_cb(void* button)
|
static void b_back_cb(void* button) {
|
||||||
{
|
|
||||||
subMenu = false; //we're not entering a submenu
|
subMenu = false; //we're not entering a submenu
|
||||||
gui_screen_back(); //navigate back to the previous screen
|
gui_screen_back(); //navigate back to the previous screen
|
||||||
}
|
}
|
||||||
|
|
||||||
//Callback for when the user presses the "save" button
|
//Callback for when the user presses the "save" button
|
||||||
static void b_save_cb(void* button)
|
static void b_save_cb(void* button) {
|
||||||
{
|
|
||||||
subMenu = true; //we're entering a submenu
|
subMenu = true; //we're entering a submenu
|
||||||
gui_screen_navigate(get_screen_photomodesave()); //navigate to the save screen
|
gui_screen_navigate(get_screen_photomodesave()); //navigate to the save screen
|
||||||
}
|
}
|
||||||
@@ -47,21 +30,18 @@ static POINT_STRUCT pixy_pos; //The current position of pixy's servos
|
|||||||
static POINT_STRUCT old_pos; //The last touch position on the screen
|
static POINT_STRUCT old_pos; //The last touch position on the screen
|
||||||
|
|
||||||
//Callback for when the user drags the image around
|
//Callback for when the user drags the image around
|
||||||
static void touchCB(void* touchArea, TOUCH_ACTION triggeredAction)
|
static void touchCB(void* touchArea, TOUCH_ACTION triggeredAction) {
|
||||||
{
|
|
||||||
POINT_STRUCT p = touch_get_last_point(); //get the last touched point
|
POINT_STRUCT p = touch_get_last_point(); //get the last touched point
|
||||||
|
|
||||||
switch(triggeredAction) {
|
switch(triggeredAction) {
|
||||||
case PEN_ENTER:
|
case PEN_ENTER:
|
||||||
case PEN_DOWN:
|
case PEN_DOWN:
|
||||||
old_pos = p; //If the user "newly" enters the touch area, we set the "last" position to the current
|
old_pos = p; //If the user "newly" enters the touch area, we set the "last" position to the current
|
||||||
break;
|
break;
|
||||||
|
case PEN_MOVE: //the user is moving around, he entered the screen a while ago (old_pos is set)
|
||||||
case PEN_MOVE: { //the user is moving around, he entered the screen a while ago (old_pos is set)
|
{
|
||||||
int16_t deltaX = p.x - old_pos.x; //Calculate x difference between last and current touch
|
int16_t deltaX = p.x - old_pos.x; //Calculate x difference between last and current touch
|
||||||
int16_t deltaY = p.y - old_pos.y; //Calculate y difference between last and current touch
|
int16_t deltaY = p.y - old_pos.y; //Calculate y difference between last and current touch
|
||||||
old_pos=p; //store the current touch point for the next time
|
old_pos=p; //store the current touch point for the next time
|
||||||
|
|
||||||
//printf("%d %d\n",deltaX,deltaY);
|
//printf("%d %d\n",deltaX,deltaY);
|
||||||
if(pixy_connected) {
|
if(pixy_connected) {
|
||||||
//Calculate new servo coordinates. 2 is just a proportional factor
|
//Calculate new servo coordinates. 2 is just a proportional factor
|
||||||
@@ -69,21 +49,10 @@ static void touchCB(void* touchArea, TOUCH_ACTION triggeredAction)
|
|||||||
int16_t new_y = pixy_pos.y-deltaY*2;
|
int16_t new_y = pixy_pos.y-deltaY*2;
|
||||||
|
|
||||||
//check limits
|
//check limits
|
||||||
if (new_x < 0) {
|
if(new_x<0) new_x=0;
|
||||||
new_x = 0;
|
if(new_x>1000) new_x=1000;
|
||||||
}
|
if(new_y<0) new_y=0;
|
||||||
|
if(new_y>1000) new_y=1000;
|
||||||
if (new_x > 1000) {
|
|
||||||
new_x = 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (new_y < 0) {
|
|
||||||
new_y = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (new_y > 1000) {
|
|
||||||
new_y = 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
//set pixy_pos so that the main routine can send it to the servos
|
//set pixy_pos so that the main routine can send it to the servos
|
||||||
pixy_pos.x = new_x;
|
pixy_pos.x = new_x;
|
||||||
@@ -91,21 +60,17 @@ static void touchCB(void* touchArea, TOUCH_ACTION triggeredAction)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PEN_UP:
|
case PEN_UP:
|
||||||
case PEN_LEAVE:
|
case PEN_LEAVE:
|
||||||
//printf("Leave/up\n");
|
//printf("Leave/up\n");
|
||||||
break;
|
break;
|
||||||
|
default: break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Callback for when the screen is entered/loaded
|
//Callback for when the screen is entered/loaded
|
||||||
static void enter(void* screen)
|
static void enter(void* screen) {
|
||||||
{
|
|
||||||
tft_clear(WHITE);
|
tft_clear(WHITE);
|
||||||
|
|
||||||
tft_print_line(5,5,BLACK,TRANSPARENT,0,"Drag the image around and ");
|
tft_print_line(5,5,BLACK,TRANSPARENT,0,"Drag the image around and ");
|
||||||
@@ -148,15 +113,13 @@ static void enter(void* screen)
|
|||||||
|
|
||||||
//Pixy stuff
|
//Pixy stuff
|
||||||
pixy_connected = (pixy_init()==0); //try to connect to pixy
|
pixy_connected = (pixy_init()==0); //try to connect to pixy
|
||||||
|
|
||||||
if(pixy_connected && !subMenu) { //pixy is connected, but we are not coming from a submenu
|
if(pixy_connected && !subMenu) { //pixy is connected, but we are not coming from a submenu
|
||||||
pixy_pos.x=pixy_pos.y=500; //reset servo positions to center
|
pixy_pos.x=pixy_pos.y=500; //reset servo positions to center
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Callback for when the screen is left/unloaded
|
//Callback for when the screen is left/unloaded
|
||||||
static void leave(void* screen)
|
static void leave(void* screen) {
|
||||||
{
|
|
||||||
//remove buttons and touch area.
|
//remove buttons and touch area.
|
||||||
gui_button_remove(&b_back);
|
gui_button_remove(&b_back);
|
||||||
gui_button_remove(&b_save);
|
gui_button_remove(&b_save);
|
||||||
@@ -165,20 +128,16 @@ static void leave(void* screen)
|
|||||||
|
|
||||||
//Callback for when the screen should be updated
|
//Callback for when the screen should be updated
|
||||||
//This is the main loop of the screen. This method will be called repeatedly
|
//This is the main loop of the screen. This method will be called repeatedly
|
||||||
static void update(void* screen)
|
static void update(void* screen) {
|
||||||
{
|
|
||||||
//Note: The only way to detect that pixy has been disconnected is if a command fails. There's no pixy_is_connected method yet :'(
|
//Note: The only way to detect that pixy has been disconnected is if a command fails. There's no pixy_is_connected method yet :'(
|
||||||
|
|
||||||
if(!pixy_connected) { //Pixy not connected
|
if(!pixy_connected) { //Pixy not connected
|
||||||
pixy_close(); //Ensure that all pixy resources are freed (failsafe)
|
pixy_close(); //Ensure that all pixy resources are freed (failsafe)
|
||||||
|
|
||||||
if(pixy_init()==0) { //try to connect to pixy
|
if(pixy_init()==0) { //try to connect to pixy
|
||||||
pixy_connected=true;
|
pixy_connected=true;
|
||||||
|
|
||||||
if(!subMenu) { //we're not coming from a submenu
|
if(!subMenu) { //we're not coming from a submenu
|
||||||
pixy_pos.x=pixy_pos.y=500; //reset servo positions to center
|
pixy_pos.x=pixy_pos.y=500; //reset servo positions to center
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("pixy (re)initialized\n");
|
printf("pixy (re)initialized\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -202,7 +161,6 @@ static SCREEN_STRUCT screen = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
SCREEN_STRUCT* get_screen_photomode()
|
SCREEN_STRUCT* get_screen_photomode() {
|
||||||
{
|
|
||||||
return &screen;
|
return &screen;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/app/screen_photomode.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/app/screen_photomode_save.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-05-16 timolang@gmail.com 62006e0 Documented pixy_helper and implemented/finished photo-mode screens! Snap some shots!
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "screen_photomode_save.h"
|
#include "screen_photomode_save.h"
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
@@ -27,8 +13,7 @@ static BUTTON_STRUCT b_back; //Button to navigate back
|
|||||||
static TOUCH_AREA_STRUCT a_area; //Touch area to select the save-file
|
static TOUCH_AREA_STRUCT a_area; //Touch area to select the save-file
|
||||||
|
|
||||||
//Callback for when the user presses the "back" button
|
//Callback for when the user presses the "back" button
|
||||||
static void b_back_cb(void* button)
|
static void b_back_cb(void* button) {
|
||||||
{
|
|
||||||
gui_screen_back();
|
gui_screen_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,19 +32,14 @@ typedef struct FILE_LIST_ENTRY_S {
|
|||||||
static FILE_LIST_ENTRY* files_ok; //Pointer to the head of the list
|
static FILE_LIST_ENTRY* files_ok; //Pointer to the head of the list
|
||||||
|
|
||||||
//Callback for when the user selects a file to save the image into
|
//Callback for when the user selects a file to save the image into
|
||||||
static void touchCB(void* touchArea, TOUCH_ACTION triggeredAction)
|
static void touchCB(void* touchArea, TOUCH_ACTION triggeredAction) {
|
||||||
{
|
|
||||||
|
|
||||||
int y = touch_get_last_point().y-liststart; //Calculate the y-Coordinate of the touch point relative to the start of the file-list
|
int y = touch_get_last_point().y-liststart; //Calculate the y-Coordinate of the touch point relative to the start of the file-list
|
||||||
int elem = y/fontheight; //Calculate the file index
|
int elem = y/fontheight; //Calculate the file index
|
||||||
|
if(elem<0 | elem>= num_files_ok) return; //Check if the file index is valid (0,1,..,num_files_ok-1)
|
||||||
if (elem < 0 | elem >= num_files_ok) {
|
|
||||||
return; //Check if the file index is valid (0,1,..,num_files_ok-1)
|
|
||||||
}
|
|
||||||
|
|
||||||
//Search for the corresponding entry in the linked list
|
//Search for the corresponding entry in the linked list
|
||||||
FILE_LIST_ENTRY* current_entry = files_ok; //Start walking through the list, starting by the head of the list
|
FILE_LIST_ENTRY* current_entry = files_ok; //Start walking through the list, starting by the head of the list
|
||||||
|
|
||||||
for(int i=0; i<elem; i++) { //Until we have reached the file (index)
|
for(int i=0; i<elem; i++) { //Until we have reached the file (index)
|
||||||
current_entry= current_entry->next; //traverse to the next file
|
current_entry= current_entry->next; //traverse to the next file
|
||||||
}
|
}
|
||||||
@@ -105,8 +85,7 @@ static unsigned char bmpheader_data[0x7A] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
//Callback for when the screen is entered/loaded
|
//Callback for when the screen is entered/loaded
|
||||||
static void enter(void* screen)
|
static void enter(void* screen) {
|
||||||
{
|
|
||||||
tft_clear(WHITE);
|
tft_clear(WHITE);
|
||||||
|
|
||||||
|
|
||||||
@@ -132,12 +111,11 @@ static void enter(void* screen)
|
|||||||
|
|
||||||
//Callback for when the screen should be updated
|
//Callback for when the screen should be updated
|
||||||
//This is the main loop of the screen. This method will be called repeatedly
|
//This is the main loop of the screen. This method will be called repeatedly
|
||||||
static void update(void* screen)
|
static void update(void* screen) {
|
||||||
{
|
|
||||||
switch(state) {
|
switch(state) {
|
||||||
case init: { //Init State: The user just entered the screen
|
case init: //Init State: The user just entered the screen
|
||||||
|
{
|
||||||
DIRECTORY_STRUCT* dir = filesystem_dir_open("."); //open root directory
|
DIRECTORY_STRUCT* dir = filesystem_dir_open("."); //open root directory
|
||||||
|
|
||||||
if(dir==NULL) { //error while opening root directory
|
if(dir==NULL) { //error while opening root directory
|
||||||
tft_print_line(X_OFS,5,BLACK,TRANSPARENT,0,"Error accessing Filesystem");
|
tft_print_line(X_OFS,5,BLACK,TRANSPARENT,0,"Error accessing Filesystem");
|
||||||
state=error;
|
state=error;
|
||||||
@@ -150,14 +128,10 @@ static void update(void* screen)
|
|||||||
FILE_STRUCT* file = &(dir->files[i]); //Pointer to the current file/subdirectory
|
FILE_STRUCT* file = &(dir->files[i]); //Pointer to the current file/subdirectory
|
||||||
|
|
||||||
//Ignore directories, archives, hidden files, system files and files we cannot write to
|
//Ignore directories, archives, hidden files, system files and files we cannot write to
|
||||||
if (file->fattrib & (F_SYS | F_HID | F_ARC | F_DIR | F_RDO)) {
|
if(file->fattrib&(F_SYS|F_HID|F_ARC|F_DIR|F_RDO)) continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//ignore files which are not large enough
|
//ignore files which are not large enough
|
||||||
if (file->fsize < 189410) {
|
if(file->fsize<189410) continue; //size taken from an example bitmap (318x198x24)
|
||||||
continue; //size taken from an example bitmap (318x198x24)
|
|
||||||
}
|
|
||||||
|
|
||||||
nomatch=false; //at least one file matches
|
nomatch=false; //at least one file matches
|
||||||
break;
|
break;
|
||||||
@@ -166,13 +140,11 @@ static void update(void* screen)
|
|||||||
if(nomatch) { //not one file is suitable for writing
|
if(nomatch) { //not one file is suitable for writing
|
||||||
int y=5; //y-Coordinate where to start writing the error text
|
int y=5; //y-Coordinate where to start writing the error text
|
||||||
int i=0;
|
int i=0;
|
||||||
|
|
||||||
while(nomatch_text[i]!=NULL) { //for every line in the big error array
|
while(nomatch_text[i]!=NULL) { //for every line in the big error array
|
||||||
//Write the line's text and go to the next line
|
//Write the line's text and go to the next line
|
||||||
tft_print_line(X_OFS,y+i*fontheight,BLACK,TRANSPARENT,0,nomatch_text[i]);
|
tft_print_line(X_OFS,y+i*fontheight,BLACK,TRANSPARENT,0,nomatch_text[i]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
state = error;
|
state = error;
|
||||||
} else { //we have a least one suitable file
|
} else { //we have a least one suitable file
|
||||||
state = showlist;
|
state = showlist;
|
||||||
@@ -182,12 +154,10 @@ static void update(void* screen)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case showlist: { //Show List State: Where we load and present the suitable file's to the user in a list
|
case showlist: //Show List State: Where we load and present the suitable file's to the user in a list
|
||||||
|
{
|
||||||
DIRECTORY_STRUCT* dir2 = filesystem_dir_open("."); //Open the directory again
|
DIRECTORY_STRUCT* dir2 = filesystem_dir_open("."); //Open the directory again
|
||||||
|
if(dir2==NULL) return; //Error on opening? This should never happen, since it's handled in the previous state
|
||||||
if (dir2 == NULL) {
|
|
||||||
return; //Error on opening? This should never happen, since it's handled in the previous state
|
|
||||||
}
|
|
||||||
|
|
||||||
int y = 5; //y-Coordinate where to start drawing/writing text/list-elements
|
int y = 5; //y-Coordinate where to start drawing/writing text/list-elements
|
||||||
|
|
||||||
@@ -201,19 +171,14 @@ static void update(void* screen)
|
|||||||
num_files_ok = 0; //we start with 0 matching files
|
num_files_ok = 0; //we start with 0 matching files
|
||||||
|
|
||||||
FILE_LIST_ENTRY* current_entry = NULL; //We start with an empty list
|
FILE_LIST_ENTRY* current_entry = NULL; //We start with an empty list
|
||||||
|
|
||||||
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
|
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
|
||||||
FILE_STRUCT* file = &(dir2->files[i]);
|
FILE_STRUCT* file = &(dir2->files[i]);
|
||||||
|
|
||||||
//Ignore directories, archives, hidden files, system files and files we cannot write to
|
//Ignore directories, archives, hidden files, system files and files we cannot write to
|
||||||
if (file->fattrib & (F_SYS | F_HID | F_ARC | F_DIR | F_RDO)) {
|
if(file->fattrib&(F_SYS|F_HID|F_ARC|F_DIR|F_RDO)) continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//ignore files which are not large enough
|
//ignore files which are not large enough
|
||||||
if (file->fsize < 189410) {
|
if(file->fsize<189410) continue; //size taken from an example bitmap (318x198x24)
|
||||||
continue; //size taken from an example bitmap (318x198x24)
|
|
||||||
}
|
|
||||||
|
|
||||||
//Print out filename, modified date,time and file size
|
//Print out filename, modified date,time and file size
|
||||||
tft_print_formatted(X_OFS,y,BLACK,
|
tft_print_formatted(X_OFS,y,BLACK,
|
||||||
@@ -234,7 +199,6 @@ static void update(void* screen)
|
|||||||
current_entry->next = malloc(sizeof(FILE_LIST_ENTRY)); //append entry to previous entry
|
current_entry->next = malloc(sizeof(FILE_LIST_ENTRY)); //append entry to previous entry
|
||||||
current_entry = current_entry->next; //newly created entry is the current now.
|
current_entry = current_entry->next; //newly created entry is the current now.
|
||||||
}
|
}
|
||||||
|
|
||||||
current_entry->next = NULL; //we're at the end of the list (for now)
|
current_entry->next = NULL; //we're at the end of the list (for now)
|
||||||
current_entry->filename = malloc(strlen(file->fname)+1); //allocate space for the filename + zero-termination
|
current_entry->filename = malloc(strlen(file->fname)+1); //allocate space for the filename + zero-termination
|
||||||
strcpy(current_entry->filename,file->fname); //copy filename (so that we can close the directory after scanning)
|
strcpy(current_entry->filename,file->fname); //copy filename (so that we can close the directory after scanning)
|
||||||
@@ -264,9 +228,9 @@ static void update(void* screen)
|
|||||||
//do nothing and wait on user to pick a file
|
//do nothing and wait on user to pick a file
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case saving: { //Saving State: Where we save the image to the selected file
|
case saving: //Saving State: Where we save the image to the selected file
|
||||||
|
{
|
||||||
FILE_HANDLE* file = filesystem_file_open(picked_file); //try to open the selected file
|
FILE_HANDLE* file = filesystem_file_open(picked_file); //try to open the selected file
|
||||||
|
|
||||||
if(file==NULL) { //opening the file failed
|
if(file==NULL) { //opening the file failed
|
||||||
tft_print_formatted(X_OFS,190,BLUE,TRANSPARENT,0,"Could not open %s",picked_file);
|
tft_print_formatted(X_OFS,190,BLUE,TRANSPARENT,0,"Could not open %s",picked_file);
|
||||||
state=error;
|
state=error;
|
||||||
@@ -274,7 +238,6 @@ static void update(void* screen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
filesystem_file_seek(file,0); //seek to the start of the file (optional?)
|
filesystem_file_seek(file,0); //seek to the start of the file (optional?)
|
||||||
|
|
||||||
if(filesystem_file_write(file,bmpheader_data,0x7A)!=F_OK) { //Writing the header failed
|
if(filesystem_file_write(file,bmpheader_data,0x7A)!=F_OK) { //Writing the header failed
|
||||||
tft_print_formatted(X_OFS,190,BLUE,TRANSPARENT,0,"Error while writing to %s",picked_file);
|
tft_print_formatted(X_OFS,190,BLUE,TRANSPARENT,0,"Error while writing to %s",picked_file);
|
||||||
filesystem_file_close(file);
|
filesystem_file_close(file);
|
||||||
@@ -307,8 +270,7 @@ static void update(void* screen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Callback for when the screen is left/unloaded
|
//Callback for when the screen is left/unloaded
|
||||||
static void leave(void* screen)
|
static void leave(void* screen) {
|
||||||
{
|
|
||||||
gui_button_remove(&b_back); //Remove/Free the back button
|
gui_button_remove(&b_back); //Remove/Free the back button
|
||||||
|
|
||||||
if(state==picking){ //The user left the screen in the "picking"-phase
|
if(state==picking){ //The user left the screen in the "picking"-phase
|
||||||
@@ -318,7 +280,6 @@ static void leave(void* screen)
|
|||||||
if(state==picking|| state==saving || state==done) { //the user left the screen after we created the linked list
|
if(state==picking|| state==saving || state==done) { //the user left the screen after we created the linked list
|
||||||
//Iterate through the linked list and free all resources
|
//Iterate through the linked list and free all resources
|
||||||
FILE_LIST_ENTRY* current_entry = files_ok; //start with the list head
|
FILE_LIST_ENTRY* current_entry = files_ok; //start with the list head
|
||||||
|
|
||||||
while(current_entry!=NULL) { //while we're not at the end
|
while(current_entry!=NULL) { //while we're not at the end
|
||||||
FILE_LIST_ENTRY* temp = current_entry->next; //save the next pointer because we free the current element on the next line
|
FILE_LIST_ENTRY* temp = current_entry->next; //save the next pointer because we free the current element on the next line
|
||||||
free((void*)(current_entry->filename)); //free filename
|
free((void*)(current_entry->filename)); //free filename
|
||||||
@@ -335,7 +296,6 @@ static SCREEN_STRUCT screen = {
|
|||||||
update
|
update
|
||||||
};
|
};
|
||||||
|
|
||||||
SCREEN_STRUCT* get_screen_photomodesave()
|
SCREEN_STRUCT* get_screen_photomodesave() {
|
||||||
{
|
|
||||||
return &screen;
|
return &screen;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/app/screen_photomode_save.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-05-16 timolang@gmail.com 62006e0 Documented pixy_helper and implemented/finished photo-mode screens! Snap some shots!
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,3 +20,4 @@ SCREEN_STRUCT* get_screen_photomodesave();
|
|||||||
|
|
||||||
/*@}*/
|
/*@}*/
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/app/screen_pixytest.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-27 timolang@gmail.com cf72baa Introduced a Screen (sub) module and divided app into multiple screens.
|
|
||||||
* 2015-05-02 timolang@gmail.com 3281616 Added some more touch functions. Improved pixy test. Drag the Image around!
|
|
||||||
* 2015-05-09 timolang@gmail.com 0b5173e Added reference tracking.
|
|
||||||
* 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.
|
|
||||||
* 2015-05-25 timolang@gmail.com 6a61769 Reimplemented pixytest screen. Added a lot of Test-Buttons.
|
|
||||||
* 2015-06-01 aaron@duckpond.ch caa7b5c Added IRQ for user button, fixed some touchproblems.
|
|
||||||
* 2015-06-03 timolang@gmail.com 74aa186 Made pixy_test screen working again. Had to disable pixy_service. Recalibrated initial touch values.
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "screen_pixytest.h"
|
#include "screen_pixytest.h"
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
#include "numupdown.h"
|
#include "numupdown.h"
|
||||||
@@ -50,13 +30,11 @@ static uint32_t led_maxcurrent;
|
|||||||
static NUMUPDOWN_STRUCT n_led_powerlimit;
|
static NUMUPDOWN_STRUCT n_led_powerlimit;
|
||||||
|
|
||||||
|
|
||||||
static void b_back_cb(void* button)
|
static void b_back_cb(void* button) {
|
||||||
{
|
|
||||||
gui_screen_back();
|
gui_screen_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void b_servos_center_cb(void* button)
|
static void b_servos_center_cb(void* button) {
|
||||||
{
|
|
||||||
if(state==idle) {
|
if(state==idle) {
|
||||||
servo_x=500;
|
servo_x=500;
|
||||||
servo_y=500;
|
servo_y=500;
|
||||||
@@ -64,8 +42,7 @@ static void b_servos_center_cb(void* button)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void b_servos_topleft_cb(void* button)
|
static void b_servos_topleft_cb(void* button) {
|
||||||
{
|
|
||||||
if(state==idle) {
|
if(state==idle) {
|
||||||
servo_x=0;
|
servo_x=0;
|
||||||
servo_y=0;
|
servo_y=0;
|
||||||
@@ -73,8 +50,7 @@ static void b_servos_topleft_cb(void* button)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void b_servos_topright_cb(void* button)
|
static void b_servos_topright_cb(void* button) {
|
||||||
{
|
|
||||||
if(state==idle) {
|
if(state==idle) {
|
||||||
servo_x=1000;
|
servo_x=1000;
|
||||||
servo_y=0;
|
servo_y=0;
|
||||||
@@ -82,8 +58,7 @@ static void b_servos_topright_cb(void* button)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void b_servos_bottomleft_cb(void* button)
|
static void b_servos_bottomleft_cb(void* button) {
|
||||||
{
|
|
||||||
if(state==idle) {
|
if(state==idle) {
|
||||||
servo_x=0;
|
servo_x=0;
|
||||||
servo_y=1000;
|
servo_y=1000;
|
||||||
@@ -91,8 +66,7 @@ static void b_servos_bottomleft_cb(void* button)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void b_servos_bottomright_cb(void* button)
|
static void b_servos_bottomright_cb(void* button) {
|
||||||
{
|
|
||||||
if(state==idle) {
|
if(state==idle) {
|
||||||
servo_x=1000;
|
servo_x=1000;
|
||||||
servo_y=1000;
|
servo_y=1000;
|
||||||
@@ -100,56 +74,49 @@ static void b_servos_bottomright_cb(void* button)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void b_led_off_cb(void* button)
|
static void b_led_off_cb(void* button) {
|
||||||
{
|
|
||||||
if(state==idle) {
|
if(state==idle) {
|
||||||
led_color=0x000000;
|
led_color=0x000000;
|
||||||
state=update_ledcolor;
|
state=update_ledcolor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void b_led_white_cb(void* button)
|
static void b_led_white_cb(void* button) {
|
||||||
{
|
|
||||||
if(state==idle) {
|
if(state==idle) {
|
||||||
led_color=0xFFFFFF;
|
led_color=0xFFFFFF;
|
||||||
state=update_ledcolor;
|
state=update_ledcolor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void b_led_red_cb(void* button)
|
static void b_led_red_cb(void* button) {
|
||||||
{
|
|
||||||
if(state==idle) {
|
if(state==idle) {
|
||||||
led_color=0xFF0000;
|
led_color=0xFF0000;
|
||||||
state=update_ledcolor;
|
state=update_ledcolor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void b_led_green_cb(void* button)
|
static void b_led_green_cb(void* button) {
|
||||||
{
|
|
||||||
if(state==idle) {
|
if(state==idle) {
|
||||||
led_color=0x00FF00;
|
led_color=0x00FF00;
|
||||||
state=update_ledcolor;
|
state=update_ledcolor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void b_led_blue_cb(void* button)
|
static void b_led_blue_cb(void* button) {
|
||||||
{
|
|
||||||
if(state==idle) {
|
if(state==idle) {
|
||||||
led_color=0x0000FF;
|
led_color=0x0000FF;
|
||||||
state=update_ledcolor;
|
state=update_ledcolor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void n_led_powerlimit_cb(void* numupdown, int16_t value)
|
static void n_led_powerlimit_cb(void* numupdown, int16_t value) {
|
||||||
{
|
|
||||||
if(state==idle) {
|
if(state==idle) {
|
||||||
led_maxcurrent=value;
|
led_maxcurrent=value;
|
||||||
state=update_ledcurrent;
|
state=update_ledcurrent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void enter(void* screen)
|
static void enter(void* screen) {
|
||||||
{
|
|
||||||
tft_clear(WHITE);
|
tft_clear(WHITE);
|
||||||
|
|
||||||
//Back button
|
//Back button
|
||||||
@@ -304,8 +271,7 @@ static void enter(void* screen)
|
|||||||
state=detecting;
|
state=detecting;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void leave(void* screen)
|
static void leave(void* screen) {
|
||||||
{
|
|
||||||
gui_button_remove(&b_back);
|
gui_button_remove(&b_back);
|
||||||
gui_button_remove(&b_servos_center);
|
gui_button_remove(&b_servos_center);
|
||||||
gui_button_remove(&b_servos_topleft);
|
gui_button_remove(&b_servos_topleft);
|
||||||
@@ -322,8 +288,7 @@ static void leave(void* screen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void update(void* screen)
|
static void update(void* screen) {
|
||||||
{
|
|
||||||
switch(state) {
|
switch(state) {
|
||||||
case detecting: //Detecting State: Where we try to connect to the pixy
|
case detecting: //Detecting State: Where we try to connect to the pixy
|
||||||
if(pixy_init()==0) { //Pixy connection ok
|
if(pixy_init()==0) { //Pixy connection ok
|
||||||
@@ -334,20 +299,18 @@ static void update(void* screen)
|
|||||||
|
|
||||||
state = idle; //Go to next state
|
state = idle; //Go to next state
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case idle:
|
case idle:
|
||||||
pixy_service();
|
pixy_service();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case update_servos:
|
case update_servos:
|
||||||
pixy_rcs_set_position(0,servo_x);
|
pixy_rcs_set_position(0,servo_x);
|
||||||
pixy_rcs_set_position(1,servo_y);
|
pixy_rcs_set_position(1,servo_y);
|
||||||
state = idle;
|
state = idle;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case update_ledcolor: {
|
case update_ledcolor:
|
||||||
|
{
|
||||||
int32_t response;
|
int32_t response;
|
||||||
int return_value;
|
int return_value;
|
||||||
return_value = pixy_command("led_set", INT32(led_color), END_OUT_ARGS, &response, END_IN_ARGS);
|
return_value = pixy_command("led_set", INT32(led_color), END_OUT_ARGS, &response, END_IN_ARGS);
|
||||||
@@ -371,7 +334,9 @@ static SCREEN_STRUCT screen = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
SCREEN_STRUCT* get_screen_pixytest()
|
SCREEN_STRUCT* get_screen_pixytest() {
|
||||||
{
|
|
||||||
return &screen;
|
return &screen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/app/screen_pixytest.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-27 timolang@gmail.com cf72baa Introduced a Screen (sub) module and divided app into multiple screens.
|
|
||||||
* 2015-05-10 timolang@gmail.com 21edc56 Added doxyfile (doxygen) for the common folder. Started with doxygen comments for app and tft module.
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,22 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/app/screen_tracking.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-05-16 timolang@gmail.com e46314b Added Tracking Screen and implemented "Reference Tracking" and "Color Region Selection"
|
|
||||||
* 2015-05-25 timolang@gmail.com 8088014 Updated Tracking Screen so that the implementations are separated into different method groups.
|
|
||||||
* 2015-06-06 aaron@duckpond.ch 8c264c2 Comment refactoring, updated PID values
|
|
||||||
* 2015-06-06 aaron@duckpond.ch a04cda9 Refactured comments and implemented a bugfix for the PID controller
|
|
||||||
* 2015-06-07 aaron@duckpond.ch 802d3df Fixed pid controller and refactored code
|
|
||||||
* 2015-06-07 aaron@duckpond.ch 3d98ca9 Minor changes
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "screen_tracking.h"
|
#include "screen_tracking.h"
|
||||||
#include "pixy_control.h"
|
#include "pixy_control.h"
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
@@ -33,14 +14,12 @@ static CHECKBOX_STRUCT c_frame_toggle; //Checkbox to toggle video data on/off
|
|||||||
static TOUCH_AREA_STRUCT a_area; //Touch area for the color region selection
|
static TOUCH_AREA_STRUCT a_area; //Touch area for the color region selection
|
||||||
|
|
||||||
//Callback for when the user presses the "back" button
|
//Callback for when the user presses the "back" button
|
||||||
static void b_back_cb(void* button)
|
static void b_back_cb(void* button) {
|
||||||
{
|
|
||||||
gui_screen_back(); //navigate back to the previous screen
|
gui_screen_back(); //navigate back to the previous screen
|
||||||
}
|
}
|
||||||
|
|
||||||
static volatile bool frame_visible = false; //Whether or not the video data should be displayed
|
static volatile bool frame_visible = false; //Whether or not the video data should be displayed
|
||||||
static void c_frame_toggle_cb(void* checkbox, bool checked)
|
static void c_frame_toggle_cb(void *checkbox, bool checked) {
|
||||||
{
|
|
||||||
frame_visible=checked; //Set the visibility of the frame to the checked state of the checkbox
|
frame_visible=checked; //Set the visibility of the frame to the checked state of the checkbox
|
||||||
//Frame will be drawn in the main loop below
|
//Frame will be drawn in the main loop below
|
||||||
}
|
}
|
||||||
@@ -52,8 +31,7 @@ static POINT_STRUCT point2; //End point of the rectangle selected by the user (c
|
|||||||
static bool point1_valid; //Whether or not we have a valid first point
|
static bool point1_valid; //Whether or not we have a valid first point
|
||||||
|
|
||||||
//Callback for when the user presses the "select color" button
|
//Callback for when the user presses the "select color" button
|
||||||
static void b_select_cb(void* button)
|
static void b_select_cb(void* button) {
|
||||||
{
|
|
||||||
if(state==selecting) { //we're currently selecting a color region
|
if(state==selecting) { //we're currently selecting a color region
|
||||||
state = abortselecting; //Abort selecting!!
|
state = abortselecting; //Abort selecting!!
|
||||||
} else if (state==tracking) { //we're currently watching the tracking
|
} else if (state==tracking) { //we're currently watching the tracking
|
||||||
@@ -72,24 +50,20 @@ static void b_select_cb(void* button)
|
|||||||
|
|
||||||
//Callback for when the user touches the frame area to select a color region.
|
//Callback for when the user touches the frame area to select a color region.
|
||||||
//Note: It doesn't matter in which direction the user draws the rectangle, we'll normalize the coordinates later
|
//Note: It doesn't matter in which direction the user draws the rectangle, we'll normalize the coordinates later
|
||||||
static void touchCB(void* touchArea, TOUCH_ACTION triggeredAction)
|
static void touchCB(void* touchArea, TOUCH_ACTION triggeredAction) {
|
||||||
{
|
|
||||||
POINT_STRUCT p = touch_get_last_point();
|
POINT_STRUCT p = touch_get_last_point();
|
||||||
|
|
||||||
switch(triggeredAction) {
|
switch(triggeredAction) {
|
||||||
case PEN_DOWN: //The user just put down the pen
|
case PEN_DOWN: //The user just put down the pen
|
||||||
point1.x = p.x-FRAME_START_X; //Calculate x-Coordinate relative to frame start
|
point1.x = p.x-FRAME_START_X; //Calculate x-Coordinate relative to frame start
|
||||||
point1.y = p.y-FRAME_START_Y; //Calculate y-Coordinate relative to frame start
|
point1.y = p.y-FRAME_START_Y; //Calculate y-Coordinate relative to frame start
|
||||||
point1_valid= true; //The point1 is now valid
|
point1_valid= true; //The point1 is now valid
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PEN_UP: //The user took the pen away
|
case PEN_UP: //The user took the pen away
|
||||||
if(point1_valid) { //only execute if point1 is valid
|
if(point1_valid) { //only execute if point1 is valid
|
||||||
point2.x = p.x-FRAME_START_X; //Calculate x-Coordinate relative to frame start
|
point2.x = p.x-FRAME_START_X; //Calculate x-Coordinate relative to frame start
|
||||||
point2.y = p.y-FRAME_START_Y; //Calculate y-Coordinate relative to frame start
|
point2.y = p.y-FRAME_START_Y; //Calculate y-Coordinate relative to frame start
|
||||||
state = selected;
|
state = selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,8 +85,7 @@ static int16_t servo_x = 0;
|
|||||||
static int16_t servo_y = 0;
|
static int16_t servo_y = 0;
|
||||||
|
|
||||||
//Method/Callback to start our tracking
|
//Method/Callback to start our tracking
|
||||||
void tracking_our_start(void* tracking_config)
|
void tracking_our_start(void* tracking_config) {
|
||||||
{
|
|
||||||
//Activate pixy's data send program
|
//Activate pixy's data send program
|
||||||
int32_t response;
|
int32_t response;
|
||||||
int return_value;
|
int return_value;
|
||||||
@@ -125,8 +98,7 @@ void tracking_our_start(void* tracking_config)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Method/Callback to stop our tracking
|
//Method/Callback to stop our tracking
|
||||||
void tracking_our_stop(void* tracking_config)
|
void tracking_our_stop(void* tracking_config) {
|
||||||
{
|
|
||||||
//Stop pixy's data send programm
|
//Stop pixy's data send programm
|
||||||
int32_t response;
|
int32_t response;
|
||||||
int return_value;
|
int return_value;
|
||||||
@@ -134,8 +106,7 @@ void tracking_our_stop(void* tracking_config)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Method/Callback to calculate one step of our tracking
|
//Method/Callback to calculate one step of our tracking
|
||||||
void tracking_our_update(void* tracking_config, struct Block* blocks, int num_blocks)
|
void tracking_our_update(void* tracking_config, struct Block* blocks, int num_blocks) {
|
||||||
{
|
|
||||||
|
|
||||||
if(num_blocks <= 0){ // Check if there are blocks available
|
if(num_blocks <= 0){ // Check if there are blocks available
|
||||||
return; // When there are none, do nothing
|
return; // When there are none, do nothing
|
||||||
@@ -173,8 +144,7 @@ static TRACKING_CONFIG_STRUCT tracking_our = {
|
|||||||
//Methods for reference tracking implementation ahead
|
//Methods for reference tracking implementation ahead
|
||||||
|
|
||||||
//Method/Callback to start reference tracking
|
//Method/Callback to start reference tracking
|
||||||
void tracking_reference_start(void* tracking_config)
|
void tracking_reference_start(void* tracking_config) {
|
||||||
{
|
|
||||||
//Run reference tracking
|
//Run reference tracking
|
||||||
int32_t response;
|
int32_t response;
|
||||||
int return_value;
|
int return_value;
|
||||||
@@ -182,8 +152,7 @@ void tracking_reference_start(void* tracking_config)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Method/Callback to stop reference tracking
|
//Method/Callback to stop reference tracking
|
||||||
void tracking_reference_stop(void* tracking_config)
|
void tracking_reference_stop(void* tracking_config) {
|
||||||
{
|
|
||||||
//Stop reference tracking
|
//Stop reference tracking
|
||||||
int32_t response;
|
int32_t response;
|
||||||
int return_value;
|
int return_value;
|
||||||
@@ -191,8 +160,7 @@ void tracking_reference_stop(void* tracking_config)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Method/Callback to calculate one step of the reference tracking
|
//Method/Callback to calculate one step of the reference tracking
|
||||||
void tracking_reference_update(void* tracking_config, struct Block* blocks, int num_blocks)
|
void tracking_reference_update(void* tracking_config, struct Block* blocks, int num_blocks) {
|
||||||
{
|
|
||||||
//Nothing to do here. Pixy does it all.
|
//Nothing to do here. Pixy does it all.
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,18 +175,15 @@ static TRACKING_CONFIG_STRUCT tracking_reference = {
|
|||||||
static TRACKING_CONFIG_STRUCT* tracking_current;
|
static TRACKING_CONFIG_STRUCT* tracking_current;
|
||||||
|
|
||||||
//Method to set the current tracking implementation. This function is exported and should be called before getting the screen
|
//Method to set the current tracking implementation. This function is exported and should be called before getting the screen
|
||||||
void tracking_set_mode(enum Tracking_Implementation impl)
|
void tracking_set_mode(enum Tracking_Implementation impl) {
|
||||||
{
|
|
||||||
//Depending on the enum value let tracking_current point to a different setting/callback structure
|
//Depending on the enum value let tracking_current point to a different setting/callback structure
|
||||||
switch(impl) {
|
switch(impl) {
|
||||||
case OUR_TRACKING:
|
case OUR_TRACKING:
|
||||||
tracking_current = &tracking_our;
|
tracking_current = &tracking_our;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case REFERENCE_TRACKING:
|
case REFERENCE_TRACKING:
|
||||||
tracking_current = &tracking_reference;
|
tracking_current = &tracking_reference;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
tracking_current=NULL;
|
tracking_current=NULL;
|
||||||
break;
|
break;
|
||||||
@@ -226,8 +191,7 @@ void tracking_set_mode(enum Tracking_Implementation impl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Callback for when the screen is entered/loaded
|
//Callback for when the screen is entered/loaded
|
||||||
static void enter(void* screen)
|
static void enter(void* screen) {
|
||||||
{
|
|
||||||
tft_clear(WHITE);
|
tft_clear(WHITE);
|
||||||
|
|
||||||
//"Back" button
|
//"Back" button
|
||||||
@@ -284,8 +248,7 @@ static void enter(void* screen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Callback for when the screen is left/unloaded
|
//Callback for when the screen is left/unloaded
|
||||||
static void leave(void* screen)
|
static void leave(void* screen) {
|
||||||
{
|
|
||||||
//Remove buttons and checkbox
|
//Remove buttons and checkbox
|
||||||
gui_button_remove(&b_back);
|
gui_button_remove(&b_back);
|
||||||
gui_button_remove(&b_select);
|
gui_button_remove(&b_select);
|
||||||
@@ -303,14 +266,12 @@ static void leave(void* screen)
|
|||||||
|
|
||||||
//Callback for when the screen should be updated
|
//Callback for when the screen should be updated
|
||||||
//This is the main loop of the screen. This method will be called repeatedly
|
//This is the main loop of the screen. This method will be called repeatedly
|
||||||
static void update(void* screen)
|
static void update(void* screen) {
|
||||||
{
|
|
||||||
switch(state) {
|
switch(state) {
|
||||||
case detecting: //Detecting State: Where we try to connect to the pixy
|
case detecting: //Detecting State: Where we try to connect to the pixy
|
||||||
if(pixy_init()==0) { //Pixy connection ok
|
if(pixy_init()==0) { //Pixy connection ok
|
||||||
state = init; //Go to next state
|
state = init; //Go to next state
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case init: //Init State: Where we start the tracking
|
case init: //Init State: Where we start the tracking
|
||||||
@@ -345,10 +306,10 @@ static void update(void* screen)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case preselecting: { //Pre-Selecting State: Where we set up the color region selection
|
case preselecting: //Pre-Selecting State: Where we set up the color region selection
|
||||||
|
{
|
||||||
tracking_current->stop(tracking_current); //Stop tracking
|
tracking_current->stop(tracking_current); //Stop tracking
|
||||||
|
|
||||||
pixy_render_full_frame(FRAME_START_X,FRAME_START_Y); //Render one frame
|
pixy_render_full_frame(FRAME_START_X,FRAME_START_Y); //Render one frame
|
||||||
@@ -363,10 +324,10 @@ static void update(void* screen)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case selected: { //Selected State: Where we send the users selection to pixy
|
case selected: //Selected State: Where we send the users selection to pixy
|
||||||
|
{
|
||||||
//Ensure that (x1,y1) represent the top-left point and (x2,y2) the bottom-right.
|
//Ensure that (x1,y1) represent the top-left point and (x2,y2) the bottom-right.
|
||||||
unsigned int tmp;
|
unsigned int tmp;
|
||||||
|
|
||||||
if(point1.x > point2.x){
|
if(point1.x > point2.x){
|
||||||
tmp = point1.x;
|
tmp = point1.x;
|
||||||
point1.x = point2.x;
|
point1.x = point2.x;
|
||||||
@@ -378,14 +339,13 @@ static void update(void* screen)
|
|||||||
point1.y = point2.y;
|
point1.y = point2.y;
|
||||||
point2.y = tmp;
|
point2.y = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Send pixy the selected region
|
//Send pixy the selected region
|
||||||
pixy_cc_set_region(1,point1.x,point1.y,point2.x-point1.x,point2.y-point1.y);
|
pixy_cc_set_region(1,point1.x,point1.y,point2.x-point1.x,point2.y-point1.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
//no break here: We want the following code to be executed as well
|
//no break here: We want the following code to be executed as well
|
||||||
|
|
||||||
case abortselecting: { //Abort-Selecting State: Where we deinitialize the stuff we used for region selection
|
case abortselecting: //Abort-Selecting State: Where we deinitialize the stuff we used for region selection
|
||||||
|
{
|
||||||
touch_unregister_area(&a_area); //Remove the touch area. We'll no longer receive touch events
|
touch_unregister_area(&a_area); //Remove the touch area. We'll no longer receive touch events
|
||||||
|
|
||||||
b_select.text="Select Color"; //Change the button text back to "Select Color"
|
b_select.text="Select Color"; //Change the button text back to "Select Color"
|
||||||
@@ -415,7 +375,6 @@ static SCREEN_STRUCT screen = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
SCREEN_STRUCT* get_screen_tracking()
|
SCREEN_STRUCT* get_screen_tracking() {
|
||||||
{
|
|
||||||
return &screen;
|
return &screen;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/app/screen_tracking.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-05-16 timolang@gmail.com e46314b Added Tracking Screen and implemented "Reference Tracking" and "Color Region Selection"
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,56 +1,38 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/filesystem/filesystem.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-05-10 timolang@gmail.com e2bce8f Added filesystem module, tests and implementation for it in emulator.
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
#include "ll_filesystem.h"
|
#include "ll_filesystem.h"
|
||||||
|
|
||||||
bool filesystem_init()
|
bool filesystem_init() {
|
||||||
{
|
|
||||||
return ll_filesystem_init();
|
return ll_filesystem_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
DIRECTORY_STRUCT* filesystem_dir_open(const char* path)
|
DIRECTORY_STRUCT* filesystem_dir_open(const char* path) {
|
||||||
{
|
|
||||||
return ll_filesystem_dir_open(path);
|
return ll_filesystem_dir_open(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void filesystem_dir_close(DIRECTORY_STRUCT* dir)
|
void filesystem_dir_close(DIRECTORY_STRUCT* dir) {
|
||||||
{
|
|
||||||
ll_filesystem_dir_close(dir);
|
ll_filesystem_dir_close(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE_HANDLE* filesystem_file_open(const char* filename)
|
FILE_HANDLE* filesystem_file_open(const char* filename) {
|
||||||
{
|
|
||||||
return ll_filesystem_file_open(filename);
|
return ll_filesystem_file_open(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void filesystem_file_close(FILE_HANDLE* handle)
|
void filesystem_file_close(FILE_HANDLE* handle) {
|
||||||
{
|
|
||||||
ll_filesystem_file_close(handle);
|
ll_filesystem_file_close(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE_STATUS filesystem_file_seek(FILE_HANDLE* handle, uint32_t offset)
|
FILE_STATUS filesystem_file_seek(FILE_HANDLE* handle, uint32_t offset) {
|
||||||
{
|
|
||||||
return ll_filesystem_file_seek(handle,offset);
|
return ll_filesystem_file_seek(handle,offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE_STATUS filesystem_file_read(FILE_HANDLE* handle, uint8_t* buf, uint32_t size)
|
FILE_STATUS filesystem_file_read(FILE_HANDLE* handle, uint8_t* buf, uint32_t size) {
|
||||||
{
|
|
||||||
return ll_filesystem_file_read(handle,buf,size);
|
return ll_filesystem_file_read(handle,buf,size);
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE_STATUS filesystem_file_write(FILE_HANDLE* handle, uint8_t* buf, uint32_t size)
|
FILE_STATUS filesystem_file_write(FILE_HANDLE* handle, uint8_t* buf, uint32_t size) {
|
||||||
{
|
|
||||||
return ll_filesystem_file_write(handle,buf,size);
|
return ll_filesystem_file_write(handle,buf,size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/filesystem/filesystem.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-03 timolang@gmail.com 51089aa Refactored Project Structure for use with emulator
|
|
||||||
* 2015-05-10 timolang@gmail.com e2bce8f Added filesystem module, tests and implementation for it in emulator.
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#ifndef FILESYSTEM_H
|
#ifndef FILESYSTEM_H
|
||||||
#define FILESYSTEM_H
|
#define FILESYSTEM_H
|
||||||
|
|
||||||
@@ -159,3 +144,4 @@ FILE_STATUS filesystem_file_write(FILE_HANDLE* handle, uint8_t* buf, uint32_t si
|
|||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
#endif /* FILESYSTEM_H */
|
#endif /* FILESYSTEM_H */
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/gui/button.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-27 timolang@gmail.com 7c9eabc Added button support.
|
|
||||||
* 2015-05-17 timolang@gmail.com 2d46336 Improved comments in implementation of button, checkbox, numupdown, tft, touch and screen modules/submodules.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "tft.h"
|
#include "tft.h"
|
||||||
#include "touch.h"
|
#include "touch.h"
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
@@ -31,8 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//Method to calculate the shadow colors used to create the "3d" effect
|
//Method to calculate the shadow colors used to create the "3d" effect
|
||||||
void calculate_shadows(uint16_t bgcolor, uint16_t* light_shadow, uint16_t* dark_shadow)
|
void calculate_shadows(uint16_t bgcolor, uint16_t* light_shadow, uint16_t* dark_shadow) {
|
||||||
{
|
|
||||||
#define BRIGHTNESS_VAL 3 //How much the Brightness is in/decreased for button shadows (3 -> Add/Subtract 1/3 off Full Value)
|
#define BRIGHTNESS_VAL 3 //How much the Brightness is in/decreased for button shadows (3 -> Add/Subtract 1/3 off Full Value)
|
||||||
|
|
||||||
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)
|
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)
|
||||||
@@ -44,47 +29,32 @@ void calculate_shadows(uint16_t bgcolor, uint16_t* light_shadow, uint16_t* dark_
|
|||||||
b=(bgcolor&0x001F)>>0;
|
b=(bgcolor&0x001F)>>0;
|
||||||
|
|
||||||
//For the light shadow color:
|
//For the light shadow color:
|
||||||
if ((r + 0x1F / BRIGHTNESS_VAL) > 0x1F) { //Adding one third would exceed the maximum of the red channel
|
if((r + 0x1F/BRIGHTNESS_VAL) > 0x1F) //Adding one third would exceed the maximum of the red channel
|
||||||
c_light=0xF800; //Use full red
|
c_light=0xF800; //Use full red
|
||||||
} else { //adding one third to the red channel is fine
|
else //adding one third to the red channel is fine
|
||||||
c_light=(r+0x1F/BRIGHTNESS_VAL)<<11; //Use same red as in the background, but add one third
|
c_light=(r+0x1F/BRIGHTNESS_VAL)<<11; //Use same red as in the background, but add one third
|
||||||
}
|
if((g + 0x3F/BRIGHTNESS_VAL) > 0x3F) //same for the green channel
|
||||||
|
|
||||||
if ((g + 0x3F / BRIGHTNESS_VAL) > 0x3F) { //same for the green channel
|
|
||||||
c_light|=0x07E0;
|
c_light|=0x07E0;
|
||||||
} else {
|
else
|
||||||
c_light|=(g+0x3F/BRIGHTNESS_VAL)<<5;
|
c_light|=(g+0x3F/BRIGHTNESS_VAL)<<5;
|
||||||
}
|
if((b + 0x1F/BRIGHTNESS_VAL) > 0x1F) //and the blue channel
|
||||||
|
|
||||||
if ((b + 0x1F / BRIGHTNESS_VAL) > 0x1F) { //and the blue channel
|
|
||||||
c_light|=0x0018;
|
c_light|=0x0018;
|
||||||
} else {
|
else
|
||||||
c_light|=(b+0x1F/BRIGHTNESS_VAL)<<0;
|
c_light|=(b+0x1F/BRIGHTNESS_VAL)<<0;
|
||||||
}
|
|
||||||
|
|
||||||
//For the dark shadow color
|
//For the dark shadow color
|
||||||
if (r > (0x1F / BRIGHTNESS_VAL)) { //Subtracting one third would NOT exceed the minimum of the red channel
|
if(r > (0x1F/BRIGHTNESS_VAL)) //Subtracting one third would NOT exceed the minimum of the red channel
|
||||||
c_dark=(r-0x1F/BRIGHTNESS_VAL)<<11; //Use same red as in the background, but subtract one third
|
c_dark=(r-0x1F/BRIGHTNESS_VAL)<<11; //Use same red as in the background, but subtract one third
|
||||||
} else { //Subtracting one third would give us a number below zero
|
else //Subtracting one third would give us a number below zero
|
||||||
c_dark=0x0000; //use no red channel
|
c_dark=0x0000; //use no red channel
|
||||||
}
|
if(g > (0x3F/BRIGHTNESS_VAL)) //Same for the green channel
|
||||||
|
|
||||||
if (g > (0x3F / BRIGHTNESS_VAL)) { //Same for the green channel
|
|
||||||
c_dark|=(g-0x3F/BRIGHTNESS_VAL)<<5;
|
c_dark|=(g-0x3F/BRIGHTNESS_VAL)<<5;
|
||||||
}
|
if(b > (0x1F/BRIGHTNESS_VAL)) //and the blue channel
|
||||||
|
|
||||||
if (b > (0x1F / BRIGHTNESS_VAL)) { //and the blue channel
|
|
||||||
c_dark|=(b-0x1F/BRIGHTNESS_VAL)<<0;
|
c_dark|=(b-0x1F/BRIGHTNESS_VAL)<<0;
|
||||||
}
|
|
||||||
|
|
||||||
//Assign the calculated shadows to out parameters
|
//Assign the calculated shadows to out parameters
|
||||||
if (light_shadow != NULL) {
|
if(light_shadow!=NULL) *light_shadow = c_light;
|
||||||
*light_shadow = c_light;
|
if(dark_shadow!=NULL) *dark_shadow = c_dark;
|
||||||
}
|
|
||||||
|
|
||||||
if (dark_shadow != NULL) {
|
|
||||||
*dark_shadow = c_dark;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +67,8 @@ void buttons_cb(void* touchArea, TOUCH_ACTION triggeredAction)
|
|||||||
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)
|
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)
|
||||||
calculate_shadows(button->bgcolor,&c_light,&c_dark);
|
calculate_shadows(button->bgcolor,&c_light,&c_dark);
|
||||||
|
|
||||||
switch (triggeredAction) {
|
switch(triggeredAction)
|
||||||
|
{
|
||||||
case PEN_DOWN: //If the user touches the area for the "first time"
|
case PEN_DOWN: //If the user touches the area for the "first time"
|
||||||
area->hookedActions=PEN_UP|PEN_LEAVE; //for the future we only want PEN_UP and PEN_LEAVE events
|
area->hookedActions=PEN_UP|PEN_LEAVE; //for the future we only want PEN_UP and PEN_LEAVE events
|
||||||
|
|
||||||
@@ -107,7 +78,6 @@ void buttons_cb(void* touchArea, TOUCH_ACTION triggeredAction)
|
|||||||
tft_draw_line(button->base.x1+1,button->base.y2,button->base.x2-1,button->base.y2,c_light); //South
|
tft_draw_line(button->base.x1+1,button->base.y2,button->base.x2-1,button->base.y2,c_light); //South
|
||||||
tft_draw_line(button->base.x2,button->base.y1+1,button->base.x2,button->base.y2-1,c_light); //East
|
tft_draw_line(button->base.x2,button->base.y1+1,button->base.x2,button->base.y2-1,c_light); //East
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PEN_UP: //If the user took the pen away, while in the area (=button pressed!)
|
case PEN_UP: //If the user took the pen away, while in the area (=button pressed!)
|
||||||
case PEN_LEAVE: //or the user "slided out" of the area
|
case PEN_LEAVE: //or the user "slided out" of the area
|
||||||
area->hookedActions=PEN_DOWN; //for the future we only want PEN_DOWN events
|
area->hookedActions=PEN_DOWN; //for the future we only want PEN_DOWN events
|
||||||
@@ -118,21 +88,18 @@ void buttons_cb(void* touchArea, TOUCH_ACTION triggeredAction)
|
|||||||
tft_draw_line(button->base.x1+1,button->base.y2,button->base.x2-1,button->base.y2,c_dark); //South
|
tft_draw_line(button->base.x1+1,button->base.y2,button->base.x2-1,button->base.y2,c_dark); //South
|
||||||
tft_draw_line(button->base.x2,button->base.y1+1,button->base.x2,button->base.y2-1,c_dark); //East
|
tft_draw_line(button->base.x2,button->base.y1+1,button->base.x2,button->base.y2-1,c_dark); //East
|
||||||
|
|
||||||
if (triggeredAction == PEN_UP && button->callback != NULL) { //If the button got "pressed" instead of left, and the user provided a callback
|
if(triggeredAction==PEN_UP && button->callback!=NULL) //If the button got "pressed" instead of left, and the user provided a callback
|
||||||
button->callback(button); //execute the user callback
|
button->callback(button); //execute the user callback
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
break;
|
||||||
|
default:break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool gui_button_add(BUTTON_STRUCT* button)
|
bool gui_button_add(BUTTON_STRUCT* button)
|
||||||
{
|
{
|
||||||
if (touch_have_empty(1)) { //Check if the touch module can handle one additional area
|
if(touch_have_empty(1)) //Check if the touch module can handle one additional area
|
||||||
|
{
|
||||||
//Calculate width and height of the button text
|
//Calculate width and height of the button text
|
||||||
unsigned int strwidth=tft_font_width(button->font)*strlen(button->text);
|
unsigned int strwidth=tft_font_width(button->font)*strlen(button->text);
|
||||||
unsigned char strheight=tft_font_height(button->font);
|
unsigned char strheight=tft_font_height(button->font);
|
||||||
@@ -153,7 +120,6 @@ bool gui_button_add(BUTTON_STRUCT* button)
|
|||||||
} else if((button->base.y2-button->base.y1+1)<(strheight+2)) { //the provided height is too small to fit the text
|
} else if((button->base.y2-button->base.y1+1)<(strheight+2)) { //the provided height is too small to fit the text
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
gui_button_redraw(button); //call the redraw method, which will take care of drawing the entire button
|
gui_button_redraw(button); //call the redraw method, which will take care of drawing the entire button
|
||||||
return touch_register_area(&button->base); //Register the touch area and receive events for this button, from now on
|
return touch_register_area(&button->base); //Register the touch area and receive events for this button, from now on
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/gui/button.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-27 timolang@gmail.com 7c9eabc Added button support.
|
|
||||||
* 2015-04-27 timolang@gmail.com cf72baa Introduced a Screen (sub) module and divided app into multiple screens.
|
|
||||||
* 2015-05-11 timolang@gmail.com 08d9fe0 More work on doxygen module structure
|
|
||||||
* 2015-05-12 timolang@gmail.com 1402598 Added doxygen stuff for button module and some minor changes to touch, screen_main and tft module.
|
|
||||||
* 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.
|
|
||||||
* 2015-05-17 timolang@gmail.com 2d46336 Improved comments in implementation of button, checkbox, numupdown, tft, touch and screen modules/submodules.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#ifndef BUTTON_H
|
#ifndef BUTTON_H
|
||||||
#define BUTTON_H
|
#define BUTTON_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/gui/checkbox.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-27 timolang@gmail.com b300ac5 Added Checkbox support
|
|
||||||
* 2015-05-17 timolang@gmail.com 2d46336 Improved comments in implementation of button, checkbox, numupdown, tft, touch and screen modules/submodules.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "tft.h"
|
#include "tft.h"
|
||||||
#include "touch.h"
|
#include "touch.h"
|
||||||
#include "checkbox.h"
|
#include "checkbox.h"
|
||||||
@@ -35,8 +21,8 @@ void checkboxes_cb(void* touchArea, TOUCH_ACTION triggeredAction)
|
|||||||
{
|
{
|
||||||
TOUCH_AREA_STRUCT * area = (TOUCH_AREA_STRUCT*)touchArea;
|
TOUCH_AREA_STRUCT * area = (TOUCH_AREA_STRUCT*)touchArea;
|
||||||
CHECKBOX_STRUCT* checkbox = (CHECKBOX_STRUCT*)touchArea;
|
CHECKBOX_STRUCT* checkbox = (CHECKBOX_STRUCT*)touchArea;
|
||||||
|
switch(triggeredAction)
|
||||||
switch (triggeredAction) {
|
{
|
||||||
case PEN_DOWN: //If the user touches the area for the "first time"
|
case PEN_DOWN: //If the user touches the area for the "first time"
|
||||||
area->hookedActions=PEN_UP|PEN_LEAVE; //for the future we only want PEN_UP and PEN_LEAVE events
|
area->hookedActions=PEN_UP|PEN_LEAVE; //for the future we only want PEN_UP and PEN_LEAVE events
|
||||||
|
|
||||||
@@ -44,15 +30,12 @@ void checkboxes_cb(void* touchArea, TOUCH_ACTION triggeredAction)
|
|||||||
tft_draw_rectangle(checkbox->base.x1+1,checkbox->base.y1+1,checkbox->base.x2-1,checkbox->base.y2-1,ACTIVE_COLOR);
|
tft_draw_rectangle(checkbox->base.x1+1,checkbox->base.y1+1,checkbox->base.x2-1,checkbox->base.y2-1,ACTIVE_COLOR);
|
||||||
tft_draw_rectangle(checkbox->base.x1+2,checkbox->base.y1+2,checkbox->base.x2-2,checkbox->base.y2-2,ACTIVE_COLOR);
|
tft_draw_rectangle(checkbox->base.x1+2,checkbox->base.y1+2,checkbox->base.x2-2,checkbox->base.y2-2,ACTIVE_COLOR);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PEN_UP: //If the user took the pen away, while in the area (=toggle checkbox!)
|
case PEN_UP: //If the user took the pen away, while in the area (=toggle checkbox!)
|
||||||
checkbox->checked=!checkbox->checked; //Toggle checkbox state
|
checkbox->checked=!checkbox->checked; //Toggle checkbox state
|
||||||
gui_checkbox_update(checkbox); //redraw/overdraw tickmark
|
gui_checkbox_update(checkbox); //redraw/overdraw tickmark
|
||||||
|
|
||||||
if(checkbox->callback!=NULL) { //The user provided a callback
|
if(checkbox->callback!=NULL) { //The user provided a callback
|
||||||
checkbox->callback(checkbox,checkbox->checked); //Call the provided callback with the new checked state
|
checkbox->callback(checkbox,checkbox->checked); //Call the provided callback with the new checked state
|
||||||
}
|
}
|
||||||
|
|
||||||
// no break statement here!
|
// no break statement here!
|
||||||
case PEN_LEAVE: //if the user "slided out" of the area
|
case PEN_LEAVE: //if the user "slided out" of the area
|
||||||
area->hookedActions=PEN_DOWN; //for the future we only want PEN_DOWN events
|
area->hookedActions=PEN_DOWN; //for the future we only want PEN_DOWN events
|
||||||
@@ -61,37 +44,31 @@ void checkboxes_cb(void* touchArea, TOUCH_ACTION triggeredAction)
|
|||||||
tft_draw_rectangle(checkbox->base.x1+1,checkbox->base.y1+1,checkbox->base.x2-1,checkbox->base.y2-1,BACKGROUND_COLOR);
|
tft_draw_rectangle(checkbox->base.x1+1,checkbox->base.y1+1,checkbox->base.x2-1,checkbox->base.y2-1,BACKGROUND_COLOR);
|
||||||
tft_draw_rectangle(checkbox->base.x1+2,checkbox->base.y1+2,checkbox->base.x2-2,checkbox->base.y2-2,BACKGROUND_COLOR);
|
tft_draw_rectangle(checkbox->base.x1+2,checkbox->base.y1+2,checkbox->base.x2-2,checkbox->base.y2-2,BACKGROUND_COLOR);
|
||||||
break;
|
break;
|
||||||
|
default:break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gui_checkbox_add(CHECKBOX_STRUCT* checkbox)
|
bool gui_checkbox_add(CHECKBOX_STRUCT* checkbox)
|
||||||
{
|
{
|
||||||
if (touch_have_empty(1)) { //Check if the touch module can handle one additional area
|
if(touch_have_empty(1)) //Check if the touch module can handle one additional area
|
||||||
|
{
|
||||||
unsigned char size=0;
|
unsigned char size=0;
|
||||||
checkbox->base.hookedActions=PEN_DOWN; //At first we are interested in PEN_DOWN events
|
checkbox->base.hookedActions=PEN_DOWN; //At first we are interested in PEN_DOWN events
|
||||||
checkbox->base.callback = checkboxes_cb; //Use our own callback for the touch area events
|
checkbox->base.callback = checkboxes_cb; //Use our own callback for the touch area events
|
||||||
|
|
||||||
//Check the size of the checkbox
|
//Check the size of the checkbox
|
||||||
if (checkbox->base.x2 > checkbox->base.x1) {
|
if(checkbox->base.x2>checkbox->base.x1)
|
||||||
size = checkbox->base.x2 - checkbox->base.x1; //use width a as size
|
size = checkbox->base.x2 - checkbox->base.x1; //use width a as size
|
||||||
}
|
if(checkbox->base.y2>checkbox->base.y1)
|
||||||
|
{
|
||||||
if (checkbox->base.y2 > checkbox->base.y1) {
|
if((checkbox->base.y2 - checkbox->base.y1)>size) //height is larger than size
|
||||||
if ((checkbox->base.y2 - checkbox->base.y1) > size) { //height is larger than size
|
|
||||||
size = checkbox->base.y2 - checkbox->base.y1; //use height as size
|
size = checkbox->base.y2 - checkbox->base.y1; //use height as size
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(size==0) { //no size found (maybe swap x2 and x1 or y2 and y1 ?)
|
if(size==0) { //no size found (maybe swap x2 and x1 or y2 and y1 ?)
|
||||||
return false; //signal error
|
return false; //signal error
|
||||||
}
|
}
|
||||||
|
if((size&0x01)) //the size is an odd number
|
||||||
if ((size & 0x01)) { //the size is an odd number
|
|
||||||
size++; //make size an even number
|
size++; //make size an even number
|
||||||
}
|
|
||||||
|
|
||||||
//Correct x2,y2 so that the checkbox is quadratic
|
//Correct x2,y2 so that the checkbox is quadratic
|
||||||
checkbox->base.x2 = checkbox->base.x1 + size;
|
checkbox->base.x2 = checkbox->base.x1 + size;
|
||||||
|
|||||||
@@ -1,19 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/gui/checkbox.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-27 timolang@gmail.com b300ac5 Added Checkbox support
|
|
||||||
* 2015-05-11 timolang@gmail.com 08d9fe0 More work on doxygen module structure
|
|
||||||
* 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.
|
|
||||||
* 2015-05-17 timolang@gmail.com 2d46336 Improved comments in implementation of button, checkbox, numupdown, tft, touch and screen modules/submodules.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#ifndef CHECKBOX_H
|
#ifndef CHECKBOX_H
|
||||||
#define CHECKBOX_H
|
#define CHECKBOX_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/gui/numupdown.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-30 timolang@gmail.com 76ea9d8 Added num up down support.
|
|
||||||
* 2015-04-30 timolang@gmail.com b491b78 Made numupdown horizontal
|
|
||||||
* 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.
|
|
||||||
* 2015-05-17 timolang@gmail.com 2d46336 Improved comments in implementation of button, checkbox, numupdown, tft, touch and screen modules/submodules.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "tft.h"
|
#include "tft.h"
|
||||||
#include "touch.h"
|
#include "touch.h"
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
@@ -39,7 +23,6 @@ void button_up_cb(void* button)
|
|||||||
if(element->value<element->max) { //old value lies below the maximum
|
if(element->value<element->max) { //old value lies below the maximum
|
||||||
element->value++; //let's increase the value
|
element->value++; //let's increase the value
|
||||||
gui_numupdown_update(element); //and redraw everything
|
gui_numupdown_update(element); //and redraw everything
|
||||||
|
|
||||||
if(element->callback!=NULL) { //the user provided a callback
|
if(element->callback!=NULL) { //the user provided a callback
|
||||||
element->callback(element,element->value); //Call the user callback with the new value
|
element->callback(element,element->value); //Call the user callback with the new value
|
||||||
}
|
}
|
||||||
@@ -55,7 +38,6 @@ void button_down_cb(void* button)
|
|||||||
if(element->value>element->min) { //old value lies above the minimum
|
if(element->value>element->min) { //old value lies above the minimum
|
||||||
element->value--; //let's decrease the value
|
element->value--; //let's decrease the value
|
||||||
gui_numupdown_update(element); //and redraw everything
|
gui_numupdown_update(element); //and redraw everything
|
||||||
|
|
||||||
if(element->callback!=NULL) { //the user provided a callback
|
if(element->callback!=NULL) { //the user provided a callback
|
||||||
element->callback(element,element->value); //Call the user callback with the new value
|
element->callback(element,element->value); //Call the user callback with the new value
|
||||||
}
|
}
|
||||||
@@ -63,23 +45,21 @@ void button_down_cb(void* button)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Method to calculate the number of characters needed to print the provided number in decimal notation (with optional sign)
|
//Method to calculate the number of characters needed to print the provided number in decimal notation (with optional sign)
|
||||||
static uint8_t calc_text_width(int16_t val)
|
static uint8_t calc_text_width(int16_t val) {
|
||||||
{
|
|
||||||
uint8_t width = 1 + (val<0); //1 if positive, 2 if negative (to let space for sign)
|
uint8_t width = 1 + (val<0); //1 if positive, 2 if negative (to let space for sign)
|
||||||
val=abs(val); //Make the number positive
|
val=abs(val); //Make the number positive
|
||||||
|
|
||||||
while(val>=10) { //while we have two or more digits
|
while(val>=10) { //while we have two or more digits
|
||||||
val/=10; //remove one digit
|
val/=10; //remove one digit
|
||||||
width++; //add one character
|
width++; //add one character
|
||||||
}
|
}
|
||||||
|
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool gui_numupdown_add(NUMUPDOWN_STRUCT* numupdown)
|
bool gui_numupdown_add(NUMUPDOWN_STRUCT* numupdown)
|
||||||
{
|
{
|
||||||
if (touch_have_empty(2)) { //Check if the touch module can handle two additional areas
|
if(touch_have_empty(2)) //Check if the touch module can handle two additional areas
|
||||||
|
{
|
||||||
if(numupdown->min > numupdown->max) { //min is bigger than max?
|
if(numupdown->min > numupdown->max) { //min is bigger than max?
|
||||||
return false; //invalid parameter
|
return false; //invalid parameter
|
||||||
}
|
}
|
||||||
@@ -92,11 +72,7 @@ bool gui_numupdown_add(NUMUPDOWN_STRUCT* numupdown)
|
|||||||
|
|
||||||
uint8_t tw1 = calc_text_width(numupdown->max); //Calculate character width to render maximum value
|
uint8_t tw1 = calc_text_width(numupdown->max); //Calculate character width to render maximum value
|
||||||
uint8_t tw2 = calc_text_width(numupdown->min); //Calculate character width to render minimum value
|
uint8_t tw2 = calc_text_width(numupdown->min); //Calculate character width to render minimum value
|
||||||
|
if(tw2 > tw1) tw1 = tw2; //ensure tw1 contains the larger number of the two
|
||||||
if (tw2 > tw1) {
|
|
||||||
tw1 = tw2; //ensure tw1 contains the larger number of the two
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t width= tft_font_width(0)*(tw1+1); //Calculate width of the number area
|
uint8_t width= tft_font_width(0)*(tw1+1); //Calculate width of the number area
|
||||||
|
|
||||||
//Add "minus" button to the left side of the number area
|
//Add "minus" button to the left side of the number area
|
||||||
@@ -156,14 +132,12 @@ void gui_numupdown_update(NUMUPDOWN_STRUCT* numupdown)
|
|||||||
//Calculate the number area width again (see above)
|
//Calculate the number area width again (see above)
|
||||||
uint8_t tw1 = calc_text_width(numupdown->max);
|
uint8_t tw1 = calc_text_width(numupdown->max);
|
||||||
uint8_t tw2 = calc_text_width(numupdown->min);
|
uint8_t tw2 = calc_text_width(numupdown->min);
|
||||||
|
if(tw2 > tw1) tw1 = tw2;
|
||||||
if (tw2 > tw1) {
|
|
||||||
tw1 = tw2;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t width= tft_font_width(0)*(tw1+1);
|
uint8_t width= tft_font_width(0)*(tw1+1);
|
||||||
|
|
||||||
//Draw background and label of the number area
|
//Draw background and label of the number area
|
||||||
tft_fill_rectangle(numupdown->buttonDown.base.x2+2,numupdown->y,numupdown->buttonDown.base.x2+width,numupdown->buttonUp.base.y2,BASE_COLOR);
|
tft_fill_rectangle(numupdown->buttonDown.base.x2+2,numupdown->y,numupdown->buttonDown.base.x2+width,numupdown->buttonUp.base.y2,BASE_COLOR);
|
||||||
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);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/gui/numupdown.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-30 timolang@gmail.com 76ea9d8 Added num up down support.
|
|
||||||
* 2015-05-11 timolang@gmail.com 08d9fe0 More work on doxygen module structure
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#ifndef NUMUPDOWN_H
|
#ifndef NUMUPDOWN_H
|
||||||
#define NUMUPDOWN_H
|
#define NUMUPDOWN_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/gui/screen.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-27 timolang@gmail.com cf72baa Introduced a Screen (sub) module and divided app into multiple screens.
|
|
||||||
* 2015-04-27 timolang@gmail.com 77e6d0e Fixed screen implementation.
|
|
||||||
* 2015-05-10 timolang@gmail.com b6ab7c8 Fixed compiler warning in tft and screen module.
|
|
||||||
* 2015-05-17 timolang@gmail.com 2d46336 Improved comments in implementation of button, checkbox, numupdown, tft, touch and screen modules/submodules.
|
|
||||||
* 2015-06-01 timolang@gmail.com eb573bc Finalized calibration. Fixed a bug in screen module.
|
|
||||||
* 2015-06-06 timolang@gmail.com c06661d Fixed some outdated comments in source code. Documented Gui Module in docu.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
/* The idea is as follows:
|
/* The idea is as follows:
|
||||||
@@ -32,23 +14,19 @@ static SCREEN_STRUCT* screen_list = NULL; //Head of the linked list which stores
|
|||||||
static SCREEN_STRUCT* screen_current = NULL; //Pointer to the current screen (= tail of the list)
|
static SCREEN_STRUCT* screen_current = NULL; //Pointer to the current screen (= tail of the list)
|
||||||
static volatile SCREEN_STRUCT* screen_goto = NULL; //Screen we should navigate to once we enter the gui_screen_update() method again
|
static volatile SCREEN_STRUCT* screen_goto = NULL; //Screen we should navigate to once we enter the gui_screen_update() method again
|
||||||
|
|
||||||
SCREEN_STRUCT* gui_screen_get_current()
|
SCREEN_STRUCT* gui_screen_get_current() {
|
||||||
{
|
|
||||||
return screen_current;
|
return screen_current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void gui_screen_update()
|
void gui_screen_update() {
|
||||||
{
|
|
||||||
if(screen_goto!=NULL) { //we received the task to switch the screen
|
if(screen_goto!=NULL) { //we received the task to switch the screen
|
||||||
SCREEN_STRUCT* go = (SCREEN_STRUCT*) screen_goto; //Backup volatile variable
|
SCREEN_STRUCT* go = (SCREEN_STRUCT*) screen_goto; //Backup volatile variable
|
||||||
screen_goto=NULL; //reset the "goto instruction", since we're processing it now
|
screen_goto=NULL; //reset the "goto instruction", since we're processing it now
|
||||||
|
|
||||||
if(go->next!=NULL) { //The screen is not the last in the list, so we're going back
|
if(go->next!=NULL) { //The screen is not the last in the list, so we're going back
|
||||||
if(go->next!=screen_current) { //this condition should always be false
|
if(go->next!=screen_current) { //this condition should always be false
|
||||||
return; //list corrupted?
|
return; //list corrupted?
|
||||||
}
|
}
|
||||||
|
|
||||||
screen_current->on_leave(screen_current); //let the current screen free/unregister it's resources
|
screen_current->on_leave(screen_current); //let the current screen free/unregister it's resources
|
||||||
go->next=NULL; //remove the current screen from the list
|
go->next=NULL; //remove the current screen from the list
|
||||||
} else { //we're going forward (to a new screen)
|
} else { //we're going forward (to a new screen)
|
||||||
@@ -59,7 +37,6 @@ void gui_screen_update()
|
|||||||
screen_list=go; //set the new screen as list-head
|
screen_list=go; //set the new screen as list-head
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
go->on_enter(go); //let the new screen allocate/register it's resources
|
go->on_enter(go); //let the new screen allocate/register it's resources
|
||||||
screen_current = go; //the new screen is now the current screen. Transition done
|
screen_current = go; //the new screen is now the current screen. Transition done
|
||||||
}
|
}
|
||||||
@@ -71,40 +48,28 @@ void gui_screen_update()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool gui_screen_navigate(SCREEN_STRUCT* screen)
|
bool gui_screen_navigate(SCREEN_STRUCT* screen) {
|
||||||
{
|
|
||||||
if(screen==NULL || screen==screen_current || screen==screen_goto) { //invalid argument passed
|
if(screen==NULL || screen==screen_current || screen==screen_goto) { //invalid argument passed
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
screen->next = NULL; //this will become the new tail of the list, so the next pointer must be NULL
|
screen->next = NULL; //this will become the new tail of the list, so the next pointer must be NULL
|
||||||
screen_goto=screen; //"send message" to main loop, to switch the screen
|
screen_goto=screen; //"send message" to main loop, to switch the screen
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gui_screen_back()
|
bool gui_screen_back() {
|
||||||
{
|
|
||||||
if(screen_list==NULL) { //the list head is emtpy, nothing to go back to
|
if(screen_list==NULL) { //the list head is emtpy, nothing to go back to
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCREEN_STRUCT* current = screen_list;
|
SCREEN_STRUCT* current = screen_list;
|
||||||
SCREEN_STRUCT* last = NULL;
|
SCREEN_STRUCT* last = NULL;
|
||||||
|
|
||||||
//Find second last element in list
|
//Find second last element in list
|
||||||
while(current->next != NULL) {
|
while(current->next != NULL) {
|
||||||
last = current;
|
last = current;
|
||||||
current = current->next;
|
current = current->next;
|
||||||
}
|
}
|
||||||
|
if(last==NULL) return false; //There's only a single screen, there's no going back here
|
||||||
if (last == NULL) {
|
if(current!=screen_current) return false; //The last entry in the list is not the current screen. List corrupted?
|
||||||
return false; //There's only a single screen, there's no going back here
|
|
||||||
}
|
|
||||||
|
|
||||||
if (current != screen_current) {
|
|
||||||
return false; //The last entry in the list is not the current screen. List corrupted?
|
|
||||||
}
|
|
||||||
|
|
||||||
screen_goto=last; //"send message" to main loop, to switch the screen
|
screen_goto=last; //"send message" to main loop, to switch the screen
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/gui/screen.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-27 timolang@gmail.com cf72baa Introduced a Screen (sub) module and divided app into multiple screens.
|
|
||||||
* 2015-04-27 timolang@gmail.com 77e6d0e Fixed screen implementation.
|
|
||||||
* 2015-05-11 timolang@gmail.com 08d9fe0 More work on doxygen module structure
|
|
||||||
* 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.
|
|
||||||
* 2015-05-17 timolang@gmail.com 2d46336 Improved comments in implementation of button, checkbox, numupdown, tft, touch and screen modules/submodules.
|
|
||||||
* 2015-06-06 timolang@gmail.com c06661d Fixed some outdated comments in source code. Documented Gui Module in docu.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#ifndef SCREEN_H
|
#ifndef SCREEN_H
|
||||||
#define SCREEN_H
|
#define SCREEN_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/lowlevel/ll_filesystem.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-05-10 timolang@gmail.com e2bce8f Added filesystem module, tests and implementation for it in emulator.
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,21 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/lowlevel/ll_system.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-03 timolang@gmail.com 1f2af9f Added more tft functions to common and emulator. Fixed eventloop.
|
|
||||||
* 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
|
|
||||||
* 2015-04-03 timolang@gmail.com 9a1d12a Refactored discovery, to use new project structure. Almost ready.
|
|
||||||
* 2015-04-25 timolang@gmail.com 3d1e4b2 Simplified code a bit. Emulator does not work stable when replugging pixy.
|
|
||||||
* 2015-04-25 timolang@gmail.com 0858b0d Fixed some bugs when receiving large data.
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/lowlevel/ll_tft.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-03 timolang@gmail.com 51089aa Refactored Project Structure for use with emulator
|
|
||||||
* 2015-04-03 timolang@gmail.com 1f2af9f Added more tft functions to common and emulator. Fixed eventloop.
|
|
||||||
* 2015-04-03 timolang@gmail.com 9a1d12a Refactored discovery, to use new project structure. Almost ready.
|
|
||||||
* 2015-04-03 timolang@gmail.com 1aa9194 Fixed Drawing of rects in Emulator. Got frames from pixy to emulator. Slooooow.
|
|
||||||
* 2015-04-27 aaron@duckpond.ch aed90ef Drawcircle added (emulator)
|
|
||||||
* 2015-04-27 timolang@gmail.com e249fb2 Added font support
|
|
||||||
* 2015-04-27 aaron@duckpond.ch f0a6c3b Implemented init functions for gpio, fsmc and display
|
|
||||||
* 2015-04-27 aaron@duckpond.ch 0b61f21 Fixed misplacement of prototypes in ll_tft.h and implemented a propper init function.
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
@@ -58,3 +37,5 @@ uint8_t ll_tft_font_width(uint8_t fontnum);
|
|||||||
void ll_tft_draw_char(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, char c);
|
void ll_tft_draw_char(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, char c);
|
||||||
|
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/lowlevel/ll_touch.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-27 timolang@gmail.com 259d446 Added touch support to emulator. Implemented basic touch function.
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
|||||||
@@ -1,39 +1,19 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/system/system.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-03 timolang@gmail.com 1f2af9f Added more tft functions to common and emulator. Fixed eventloop.
|
|
||||||
* 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
|
|
||||||
* 2015-04-25 timolang@gmail.com 3d1e4b2 Simplified code a bit. Emulator does not work stable when replugging pixy.
|
|
||||||
* 2015-04-25 timolang@gmail.com 0858b0d Fixed some bugs when receiving large data.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "ll_system.h"
|
#include "ll_system.h"
|
||||||
|
|
||||||
|
|
||||||
bool system_init()
|
bool system_init() {
|
||||||
{
|
|
||||||
return ll_system_init();
|
return ll_system_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void system_delay(uint32_t msec)
|
void system_delay(uint32_t msec) {
|
||||||
{
|
|
||||||
ll_system_delay(msec);
|
ll_system_delay(msec);
|
||||||
}
|
}
|
||||||
|
|
||||||
void system_process()
|
void system_process() {
|
||||||
{
|
|
||||||
ll_system_process();
|
ll_system_process();
|
||||||
}
|
}
|
||||||
|
|
||||||
void system_toggle_led()
|
void system_toggle_led() {
|
||||||
{
|
|
||||||
ll_system_toggle_led();
|
ll_system_toggle_led();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/system/system.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-03 timolang@gmail.com 1f2af9f Added more tft functions to common and emulator. Fixed eventloop.
|
|
||||||
* 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
|
|
||||||
* 2015-04-25 timolang@gmail.com 3d1e4b2 Simplified code a bit. Emulator does not work stable when replugging pixy.
|
|
||||||
* 2015-04-25 timolang@gmail.com 0858b0d Fixed some bugs when receiving large data.
|
|
||||||
* 2015-05-11 timolang@gmail.com 08d9fe0 More work on doxygen module structure
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#ifndef SYSTEM_H
|
#ifndef SYSTEM_H
|
||||||
#define SYSTEM_H
|
#define SYSTEM_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/tft/tft.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-03 timolang@gmail.com 51089aa Refactored Project Structure for use with emulator
|
|
||||||
* 2015-04-03 timolang@gmail.com 1f2af9f Added more tft functions to common and emulator. Fixed eventloop.
|
|
||||||
* 2015-04-03 timolang@gmail.com 1aa9194 Fixed Drawing of rects in Emulator. Got frames from pixy to emulator. Slooooow.
|
|
||||||
* 2015-04-27 aaron@duckpond.ch aed90ef Drawcircle added (emulator)
|
|
||||||
* 2015-04-27 timolang@gmail.com e249fb2 Added font support
|
|
||||||
* 2015-04-30 timolang@gmail.com 76ea9d8 Added num up down support.
|
|
||||||
* 2015-05-10 timolang@gmail.com b6ab7c8 Fixed compiler warning in tft and screen module.
|
|
||||||
* 2015-05-15 timolang@gmail.com b08a897 Added tft method to draw a bmp from filesystem. Added another font to emulator.
|
|
||||||
* 2015-05-17 timolang@gmail.com 2d46336 Improved comments in implementation of button, checkbox, numupdown, tft, touch and screen modules/submodules.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "tft.h"
|
#include "tft.h"
|
||||||
#include "ll_tft.h"
|
#include "ll_tft.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -36,71 +15,56 @@
|
|||||||
* For formatted printing implement putchar, instead of writing into a buffer and drawing that buffer afterwards
|
* For formatted printing implement putchar, instead of writing into a buffer and drawing that buffer afterwards
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool tft_init()
|
bool tft_init() {
|
||||||
{
|
|
||||||
return ll_tft_init();
|
return ll_tft_init();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tft_clear(uint16_t color)
|
void tft_clear(uint16_t color) {
|
||||||
{
|
|
||||||
ll_tft_clear(color);
|
ll_tft_clear(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
|
void tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color) {
|
||||||
{
|
|
||||||
ll_tft_draw_line(x1,y1,x2,y2,color);
|
ll_tft_draw_line(x1,y1,x2,y2,color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void tft_draw_pixel(uint16_t x, uint16_t y, uint16_t color)
|
void tft_draw_pixel(uint16_t x,uint16_t y,uint16_t color) {
|
||||||
{
|
|
||||||
ll_tft_draw_pixel(x,y,color);
|
ll_tft_draw_pixel(x,y,color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tft_draw_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
|
void tft_draw_rectangle(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2, uint16_t color) {
|
||||||
{
|
|
||||||
//could be implemented with 4 lines instead of introducing a ll func
|
//could be implemented with 4 lines instead of introducing a ll func
|
||||||
ll_tft_draw_rectangle(x1,y1,x2,y2,color);
|
ll_tft_draw_rectangle(x1,y1,x2,y2,color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tft_fill_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
|
void tft_fill_rectangle(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2, uint16_t color) {
|
||||||
{
|
|
||||||
ll_tft_fill_rectangle(x1,y1,x2,y2,color);
|
ll_tft_fill_rectangle(x1,y1,x2,y2,color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tft_draw_bitmap_unscaled(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint16_t* dat)
|
void tft_draw_bitmap_unscaled(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint16_t* dat) {
|
||||||
{
|
|
||||||
ll_tft_draw_bitmap_unscaled(x,y,width,height,dat);
|
ll_tft_draw_bitmap_unscaled(x,y,width,height,dat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tft_draw_circle(uint16_t x, uint16_t y, uint16_t r, uint16_t color)
|
void tft_draw_circle(uint16_t x, uint16_t y, uint16_t r, uint16_t color) {
|
||||||
{
|
|
||||||
ll_tft_draw_circle(x, y, r, color);
|
ll_tft_draw_circle(x, y, r, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t tft_num_fonts()
|
uint8_t tft_num_fonts() {
|
||||||
{
|
|
||||||
return ll_tft_num_fonts();
|
return ll_tft_num_fonts();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t tft_font_height(uint8_t fontnum)
|
uint8_t tft_font_height(uint8_t fontnum) {
|
||||||
{
|
|
||||||
return ll_tft_font_height(fontnum);
|
return ll_tft_font_height(fontnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t tft_font_width(uint8_t fontnum)
|
uint8_t tft_font_width(uint8_t fontnum) {
|
||||||
{
|
|
||||||
return ll_tft_font_width(fontnum);
|
return ll_tft_font_width(fontnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Print line can be done with multiple calls to draw_char
|
//Print line can be done with multiple calls to draw_char
|
||||||
void tft_print_line(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, const char* text)
|
void tft_print_line(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, const char* text) {
|
||||||
{
|
if(font>=ll_tft_num_fonts()) return; //invalid font index
|
||||||
if (font >= ll_tft_num_fonts()) {
|
|
||||||
return; //invalid font index
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int i=0; i<strlen(text); i++) { //for each char in the line
|
for(int i=0; i<strlen(text); i++) { //for each char in the line
|
||||||
ll_tft_draw_char(x,y,color,bgcolor, font, text[i]); //draw the char
|
ll_tft_draw_char(x,y,color,bgcolor, font, text[i]); //draw the char
|
||||||
x+=ll_tft_font_width(font); //and increase the x position
|
x+=ll_tft_font_width(font); //and increase the x position
|
||||||
@@ -108,8 +72,7 @@ void tft_print_line(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, ui
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Printing a formatted line can be done by printing the line in a buffer using "sprintf" and then calling print_line
|
//Printing a formatted line can be done by printing the line in a buffer using "sprintf" and then calling print_line
|
||||||
void tft_print_formatted(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, const char* format, ...)
|
void tft_print_formatted(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, const char* format, ...) {
|
||||||
{
|
|
||||||
static char buffer[128]; //buffer to save the formatted text into
|
static char buffer[128]; //buffer to save the formatted text into
|
||||||
|
|
||||||
//Since we have variable arguments, we need to forward them. We have to use vsprintf instead of sprintf for that.
|
//Since we have variable arguments, we need to forward them. We have to use vsprintf instead of sprintf for that.
|
||||||
@@ -120,20 +83,17 @@ void tft_print_formatted(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolo
|
|||||||
va_end(args); //end the varg-list
|
va_end(args); //end the varg-list
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tft_draw_bitmap_file_unscaled(uint16_t x, uint16_t y, const char* filename)
|
bool tft_draw_bitmap_file_unscaled(uint16_t x, uint16_t y, const char* filename) {
|
||||||
{
|
|
||||||
//This method reads a .bmp file from the filesystem and tries to draw it.
|
//This method reads a .bmp file from the filesystem and tries to draw it.
|
||||||
//Note: The bmp implementation is not complete, it has some limitations and it makes assumptions. See doxygen comment for this method.
|
//Note: The bmp implementation is not complete, it has some limitations and it makes assumptions. See doxygen comment for this method.
|
||||||
//Source Copied and adapted from: http://stackoverflow.com/a/17040962/2606757
|
//Source Copied and adapted from: http://stackoverflow.com/a/17040962/2606757
|
||||||
|
|
||||||
FILE_HANDLE* file = filesystem_file_open(filename); //try to open the file
|
FILE_HANDLE* file = filesystem_file_open(filename); //try to open the file
|
||||||
|
|
||||||
if(file==NULL) { //file opening failed
|
if(file==NULL) { //file opening failed
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char info[54];
|
unsigned char info[54];
|
||||||
|
|
||||||
if(filesystem_file_read(file,info,54)!=F_OK) { //try to read the 54 byte header
|
if(filesystem_file_read(file,info,54)!=F_OK) { //try to read the 54 byte header
|
||||||
filesystem_file_close(file);
|
filesystem_file_close(file);
|
||||||
return false; //reading the header failed
|
return false; //reading the header failed
|
||||||
@@ -151,12 +111,12 @@ bool tft_draw_bitmap_file_unscaled(uint16_t x, uint16_t y, const char* filename)
|
|||||||
|
|
||||||
unsigned char data [row_padded]; //allocate space for one row (incl. padding)
|
unsigned char data [row_padded]; //allocate space for one row (incl. padding)
|
||||||
|
|
||||||
for (int i = 0; i < height; i++) { //for each row
|
for(int i = 0; i < height; i++) //for each row
|
||||||
|
{
|
||||||
filesystem_file_read(file,data,row_padded); //read row into buffer
|
filesystem_file_read(file,data,row_padded); //read row into buffer
|
||||||
|
for(int j = 0; j < width*depth; j += depth) //for each pixel
|
||||||
for (int j = 0; j < width * depth; j += depth) { //for each pixel
|
{
|
||||||
unsigned char a,r,g,b;
|
unsigned char a,r,g,b;
|
||||||
|
|
||||||
if(depth==4) { //a,r,g,b 8bit each
|
if(depth==4) { //a,r,g,b 8bit each
|
||||||
a = data[j];
|
a = data[j];
|
||||||
r = data[j+1];
|
r = data[j+1];
|
||||||
|
|||||||
@@ -1,28 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/tft/tft.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-03 timolang@gmail.com 51089aa Refactored Project Structure for use with emulator
|
|
||||||
* 2015-04-03 timolang@gmail.com 1f2af9f Added more tft functions to common and emulator. Fixed eventloop.
|
|
||||||
* 2015-04-03 timolang@gmail.com 1aa9194 Fixed Drawing of rects in Emulator. Got frames from pixy to emulator. Slooooow.
|
|
||||||
* 2015-04-27 aaron@duckpond.ch aed90ef Drawcircle added (emulator)
|
|
||||||
* 2015-04-27 timolang@gmail.com e249fb2 Added font support
|
|
||||||
* 2015-04-30 timolang@gmail.com 76ea9d8 Added num up down support.
|
|
||||||
* 2015-05-04 aaron@duckpond.ch c224d40 Changed display init
|
|
||||||
* 2015-05-10 timolang@gmail.com 21edc56 Added doxyfile (doxygen) for the common folder. Started with doxygen comments for app and tft module.
|
|
||||||
* 2015-05-11 timolang@gmail.com a175a2f Added doxygen docu for touch module
|
|
||||||
* 2015-05-11 timolang@gmail.com 08d9fe0 More work on doxygen module structure
|
|
||||||
* 2015-05-12 timolang@gmail.com 1402598 Added doxygen stuff for button module and some minor changes to touch, screen_main and tft module.
|
|
||||||
* 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.
|
|
||||||
* 2015-05-15 timolang@gmail.com b08a897 Added tft method to draw a bmp from filesystem. Added another font to emulator.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#ifndef TFT_H
|
#ifndef TFT_H
|
||||||
#define TFT_H
|
#define TFT_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/touch/screen_calibrate.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-06-01 timolang@gmail.com 06227da Added calibrate screen (WIP). fixed bug in emulator drawing.
|
|
||||||
* 2015-06-01 timolang@gmail.com eb573bc Finalized calibration. Fixed a bug in screen module.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "screen_calibrate.h"
|
#include "screen_calibrate.h"
|
||||||
#include "tft.h"
|
#include "tft.h"
|
||||||
#include "touch.h"
|
#include "touch.h"
|
||||||
@@ -20,18 +6,15 @@
|
|||||||
extern volatile bool calibration; //from touch.c
|
extern volatile bool calibration; //from touch.c
|
||||||
|
|
||||||
|
|
||||||
static void enter(void* screen)
|
static void enter(void* screen) {
|
||||||
{
|
|
||||||
tft_clear(BLACK);
|
tft_clear(BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void leave(void* screen)
|
static void leave(void* screen) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update(void* screen)
|
static void update(void* screen) {
|
||||||
{
|
|
||||||
int x1,y1,x2,y2,dx,dy;
|
int x1,y1,x2,y2,dx,dy;
|
||||||
|
|
||||||
|
|
||||||
@@ -41,9 +24,7 @@ static void update(void* screen)
|
|||||||
tft_draw_line(CCENTER,CBEGIN,CCENTER,CEND,WHITE); //Draw Cross
|
tft_draw_line(CCENTER,CBEGIN,CCENTER,CEND,WHITE); //Draw Cross
|
||||||
tft_draw_line(CBEGIN,CCENTER,CEND,CCENTER,WHITE); //Draw Cross
|
tft_draw_line(CBEGIN,CCENTER,CEND,CCENTER,WHITE); //Draw Cross
|
||||||
calibration=1; //TouchX + TouchY Values will not be converted to Pixels
|
calibration=1; //TouchX + TouchY Values will not be converted to Pixels
|
||||||
|
|
||||||
while(calibration); //Wait on PenUp
|
while(calibration); //Wait on PenUp
|
||||||
|
|
||||||
POINT_STRUCT p1 = touch_get_last_point();
|
POINT_STRUCT p1 = touch_get_last_point();
|
||||||
x1=p1.x;
|
x1=p1.x;
|
||||||
y1=p1.y;
|
y1=p1.y;
|
||||||
@@ -53,9 +34,7 @@ static void update(void* screen)
|
|||||||
tft_draw_line(DWIDTH-CCENTER,DHEIGHT-CBEGIN,DWIDTH-CCENTER,DHEIGHT-CEND,WHITE);
|
tft_draw_line(DWIDTH-CCENTER,DHEIGHT-CBEGIN,DWIDTH-CCENTER,DHEIGHT-CEND,WHITE);
|
||||||
tft_draw_line(DWIDTH-CBEGIN,DHEIGHT-CCENTER,DWIDTH-CEND,DHEIGHT-CCENTER,WHITE);
|
tft_draw_line(DWIDTH-CBEGIN,DHEIGHT-CCENTER,DWIDTH-CEND,DHEIGHT-CCENTER,WHITE);
|
||||||
calibration=1;
|
calibration=1;
|
||||||
|
|
||||||
while(calibration);
|
while(calibration);
|
||||||
|
|
||||||
POINT_STRUCT p2 = touch_get_last_point();
|
POINT_STRUCT p2 = touch_get_last_point();
|
||||||
x2=p2.x;
|
x2=p2.x;
|
||||||
y2=p2.y;
|
y2=p2.y;
|
||||||
@@ -65,9 +44,7 @@ static void update(void* screen)
|
|||||||
tft_draw_line(CCENTER,DHEIGHT-CBEGIN,CCENTER,DHEIGHT-CEND,WHITE);
|
tft_draw_line(CCENTER,DHEIGHT-CBEGIN,CCENTER,DHEIGHT-CEND,WHITE);
|
||||||
tft_draw_line(CBEGIN,DHEIGHT-CCENTER,CEND,DHEIGHT-CCENTER,WHITE);
|
tft_draw_line(CBEGIN,DHEIGHT-CCENTER,CEND,DHEIGHT-CCENTER,WHITE);
|
||||||
calibration=1;
|
calibration=1;
|
||||||
|
|
||||||
while(calibration);
|
while(calibration);
|
||||||
|
|
||||||
POINT_STRUCT p3 = touch_get_last_point();
|
POINT_STRUCT p3 = touch_get_last_point();
|
||||||
x1+=p3.x; //Add(!) values. We'll build the average later
|
x1+=p3.x; //Add(!) values. We'll build the average later
|
||||||
y2+=p3.y;
|
y2+=p3.y;
|
||||||
@@ -77,9 +54,7 @@ static void update(void* screen)
|
|||||||
tft_draw_line(DWIDTH-CCENTER,CBEGIN,DWIDTH-CCENTER,CEND,WHITE);
|
tft_draw_line(DWIDTH-CCENTER,CBEGIN,DWIDTH-CCENTER,CEND,WHITE);
|
||||||
tft_draw_line(DWIDTH-CBEGIN,CCENTER,DWIDTH-CEND,CCENTER,WHITE);
|
tft_draw_line(DWIDTH-CBEGIN,CCENTER,DWIDTH-CEND,CCENTER,WHITE);
|
||||||
calibration=1;
|
calibration=1;
|
||||||
|
|
||||||
while(calibration);
|
while(calibration);
|
||||||
|
|
||||||
POINT_STRUCT p4 = touch_get_last_point();
|
POINT_STRUCT p4 = touch_get_last_point();
|
||||||
x2+=p4.x;
|
x2+=p4.x;
|
||||||
y1+=p4.y;
|
y1+=p4.y;
|
||||||
@@ -100,9 +75,7 @@ static void update(void* screen)
|
|||||||
tft_print_line(50,120,WHITE,BLACK,0,"Calibration Done. Press anywhere");
|
tft_print_line(50,120,WHITE,BLACK,0,"Calibration Done. Press anywhere");
|
||||||
|
|
||||||
calibration=1;
|
calibration=1;
|
||||||
|
|
||||||
while(calibration);
|
while(calibration);
|
||||||
|
|
||||||
gui_screen_back();
|
gui_screen_back();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -115,7 +88,8 @@ static SCREEN_STRUCT screen = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
SCREEN_STRUCT* get_screen_calibrate()
|
SCREEN_STRUCT* get_screen_calibrate() {
|
||||||
{
|
|
||||||
return &screen;
|
return &screen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/touch/screen_calibrate.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-06-01 timolang@gmail.com 06227da Added calibrate screen (WIP). fixed bug in emulator drawing.
|
|
||||||
* 2015-06-01 timolang@gmail.com eb573bc Finalized calibration. Fixed a bug in screen module.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,21 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/touch/touch.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-27 timolang@gmail.com 259d446 Added touch support to emulator. Implemented basic touch function.
|
|
||||||
* 2015-05-02 timolang@gmail.com 3281616 Added some more touch functions. Improved pixy test. Drag the Image around!
|
|
||||||
* 2015-05-17 timolang@gmail.com 2d46336 Improved comments in implementation of button, checkbox, numupdown, tft, touch and screen modules/submodules.
|
|
||||||
* 2015-06-01 timolang@gmail.com 06227da Added calibrate screen (WIP). fixed bug in emulator drawing.
|
|
||||||
* 2015-06-01 timolang@gmail.com eb573bc Finalized calibration. Fixed a bug in screen module.
|
|
||||||
* 2015-06-06 timolang@gmail.com c06661d Fixed some outdated comments in source code. Documented Gui Module in docu.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "touch.h"
|
#include "touch.h"
|
||||||
#include "ll_touch.h"
|
#include "ll_touch.h"
|
||||||
#include "screen_calibrate.h"
|
#include "screen_calibrate.h"
|
||||||
@@ -48,8 +30,7 @@ int cal_ys = 10;
|
|||||||
int cal_dy=100;
|
int cal_dy=100;
|
||||||
|
|
||||||
|
|
||||||
void touch_set_calibration_values(int xs, int dx, int ys, int dy)
|
void touch_set_calibration_values(int xs, int dx, int ys, int dy) {
|
||||||
{
|
|
||||||
cal_xs = xs;
|
cal_xs = xs;
|
||||||
cal_ys = ys;
|
cal_ys = ys;
|
||||||
cal_dx = dx;
|
cal_dx = dx;
|
||||||
@@ -58,34 +39,33 @@ void touch_set_calibration_values(int xs, int dx, int ys, int dy)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool touch_init()
|
bool touch_init() {
|
||||||
{
|
|
||||||
return ll_touch_init();
|
return ll_touch_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void touch_set_value_convert_mode(bool uc)
|
void touch_set_value_convert_mode(bool uc) {
|
||||||
{
|
|
||||||
use_calibration=uc;
|
use_calibration=uc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool touch_add_raw_event(uint16_t touchX, uint16_t touchY, TOUCH_STATE state)
|
bool touch_add_raw_event(uint16_t touchX, uint16_t touchY, TOUCH_STATE state) {
|
||||||
{
|
|
||||||
//Update current and old position/state
|
//Update current and old position/state
|
||||||
bool penDown = (state==TOUCH_DOWN);
|
bool penDown = (state==TOUCH_DOWN);
|
||||||
bool oldPenDown = (oldState==TOUCH_DOWN);
|
bool oldPenDown = (oldState==TOUCH_DOWN);
|
||||||
oldState=state;
|
oldState=state;
|
||||||
|
|
||||||
if (calibration) { //If in Calibration mode
|
if(calibration) //If in Calibration mode
|
||||||
if (penDown) {
|
{
|
||||||
|
if(penDown)
|
||||||
|
{
|
||||||
pos.x=touchX;
|
pos.x=touchX;
|
||||||
pos.y=touchY;
|
pos.y=touchY;
|
||||||
} else {
|
}
|
||||||
if (oldPenDown) { //Run only if we got at least one pen down
|
else
|
||||||
|
{
|
||||||
|
if(oldPenDown) //Run only if we got at least one pen down
|
||||||
calibration=0; //Calibration finish (Touch X and Y are the values from the last measure, where the pen was down)
|
calibration=0; //Calibration finish (Touch X and Y are the values from the last measure, where the pen was down)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,107 +80,113 @@ bool touch_add_raw_event(uint16_t touchX, uint16_t touchY, TOUCH_STATE state)
|
|||||||
pos.y=touchY;
|
pos.y=touchY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (penDown) { //pen is down now
|
if(penDown) //pen is down now
|
||||||
|
{
|
||||||
//tft_draw_pixel(touchX,touchY,WHITE);
|
//tft_draw_pixel(touchX,touchY,WHITE);
|
||||||
if (!oldPenDown) { //pen wasn't down before (positive edge) => First Touch
|
if(!oldPenDown) //pen wasn't down before (positive edge) => First Touch
|
||||||
for (int z = 0; z < NUM_AREAS; z++) { // For every touch area
|
{
|
||||||
|
for(int z=0; z < NUM_AREAS; z++) // For every touch area
|
||||||
|
{
|
||||||
//Check if pos is inside area
|
//Check if pos is inside area
|
||||||
if (areas[z] != NULL && touchX >= areas[z]->x1 && touchX <= areas[z]->x2 && touchY >= areas[z]->y1 && touchY <= areas[z]->y2) {
|
if(areas[z]!=NULL && touchX >= areas[z]->x1 && touchX <= areas[z]->x2 && touchY >= areas[z]->y1 && touchY <= areas[z]->y2 )
|
||||||
|
{
|
||||||
areas[z]->flags=1; //Save PenInside=1
|
areas[z]->flags=1; //Save PenInside=1
|
||||||
|
if(areas[z]->hookedActions & PEN_DOWN) //The user wants to receive pen down events
|
||||||
if (areas[z]->hookedActions & PEN_DOWN) { //The user wants to receive pen down events
|
|
||||||
areas[z]->callback(areas[z],PEN_DOWN); //Send event to user callback
|
areas[z]->callback(areas[z],PEN_DOWN); //Send event to user callback
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { //Pen was down before => Second, Third event in row
|
else //Pen was down before => Second, Third event in row
|
||||||
for (int z = 0; z < NUM_AREAS; z++) { // For every touch area
|
{
|
||||||
if (areas[z] != NULL) {
|
for(int z=0; z < NUM_AREAS; z++) // For every touch area
|
||||||
|
{
|
||||||
|
if(areas[z]!=NULL )
|
||||||
|
{
|
||||||
//Check if pos is inside area
|
//Check if pos is inside area
|
||||||
if (touchX >= areas[z]->x1 && touchX <= areas[z]->x2 && touchY >= areas[z]->y1 && touchY <= areas[z]->y2) {
|
if(touchX >= areas[z]->x1 && touchX <= areas[z]->x2 && touchY >= areas[z]->y1 && touchY <= areas[z]->y2)
|
||||||
if (areas[z]->flags == 0) { //Pen was not inside before (PenInside==0)
|
{
|
||||||
|
if(areas[z]->flags==0) //Pen was not inside before (PenInside==0)
|
||||||
|
{
|
||||||
areas[z]->flags=1; //Pen is inside now (PenInside=1)
|
areas[z]->flags=1; //Pen is inside now (PenInside=1)
|
||||||
|
if(areas[z]->hookedActions & PEN_ENTER) //The user wants to receive pen enter events
|
||||||
if (areas[z]->hookedActions & PEN_ENTER) { //The user wants to receive pen enter events
|
|
||||||
areas[z]->callback(areas[z],PEN_ENTER);
|
areas[z]->callback(areas[z],PEN_ENTER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (areas[z]->flags) { //Pos not inside area, but it was before (PenInside==1)
|
else if(areas[z]->flags) //Pos not inside area, but it was before (PenInside==1)
|
||||||
|
{
|
||||||
areas[z]->flags=0; //Pen is no longer inside (PenInside=0)
|
areas[z]->flags=0; //Pen is no longer inside (PenInside=0)
|
||||||
|
if(areas[z]->hookedActions & PEN_LEAVE) //The user wants to receive pen leave events
|
||||||
if (areas[z]->hookedActions & PEN_LEAVE) { //The user wants to receive pen leave events
|
|
||||||
areas[z]->callback(areas[z],PEN_LEAVE);
|
areas[z]->callback(areas[z],PEN_LEAVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
for(int z=0; z < NUM_AREAS; z++) // For every touch area
|
||||||
|
{
|
||||||
for (int z = 0; z < NUM_AREAS; z++) { // For every touch area
|
if(areas[z]!=NULL && (areas[z]->hookedActions&PEN_MOVE)) //User want's to receive pen move events
|
||||||
if (areas[z] != NULL && (areas[z]->hookedActions & PEN_MOVE)) { //User want's to receive pen move events
|
{
|
||||||
//Check if pos is inside area
|
//Check if pos is inside area
|
||||||
if (touchX >= areas[z]->x1 && touchX <= areas[z]->x2 && touchY >= areas[z]->y1 && touchY <= areas[z]->y2) {
|
if(touchX >= areas[z]->x1 && touchX <= areas[z]->x2 && touchY >= areas[z]->y1 && touchY <= areas[z]->y2)
|
||||||
|
{
|
||||||
areas[z]->callback(areas[z],PEN_MOVE);
|
areas[z]->callback(areas[z],PEN_MOVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { //pen is not down now
|
}
|
||||||
if (oldPenDown) { //but it was down before (negative edge)
|
else //pen is not down now
|
||||||
for (int z = 0; z < NUM_AREAS; z++) { // For every touch area
|
{
|
||||||
|
if(oldPenDown) //but it was down before (negative edge)
|
||||||
|
{
|
||||||
|
for(int z=0; z < NUM_AREAS; z++) // For every touch area
|
||||||
|
{
|
||||||
//Check if pos is inside area
|
//Check if pos is inside area
|
||||||
if (areas[z] != NULL && touchX >= areas[z]->x1 && touchX <= areas[z]->x2 && touchY >= areas[z]->y1 && touchY <= areas[z]->y2) {
|
if(areas[z]!=NULL && touchX >= areas[z]->x1 && touchX <= areas[z]->x2 && touchY >= areas[z]->y1 && touchY <= areas[z]->y2 )
|
||||||
|
{
|
||||||
areas[z]->flags=0; //The pen is no longer inside (PenInside = 0);
|
areas[z]->flags=0; //The pen is no longer inside (PenInside = 0);
|
||||||
|
if(areas[z]->hookedActions & PEN_UP) //user want's to receive pen up events
|
||||||
if (areas[z]->hookedActions & PEN_UP) { //user want's to receive pen up events
|
|
||||||
areas[z]->callback(areas[z],PEN_UP);
|
areas[z]->callback(areas[z],PEN_UP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool touch_have_empty(unsigned char num)
|
bool touch_have_empty(unsigned char num)
|
||||||
{
|
{
|
||||||
//go through pointer array and check for free spaces
|
//go through pointer array and check for free spaces
|
||||||
for (unsigned char i = 0; i < NUM_AREAS; i++) {
|
for(unsigned char i=0; i<NUM_AREAS; i++)
|
||||||
if (areas[i] == NULL) {
|
{
|
||||||
num--; //a free space was found, we need one less
|
if(areas[i]==NULL) num--; //a free space was found, we need one less
|
||||||
|
if(num==0) return true; //enough free spaces found
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num == 0) {
|
|
||||||
return true; //enough free spaces found
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false; //not enough free spaces found
|
return false; //not enough free spaces found
|
||||||
}
|
}
|
||||||
|
|
||||||
bool touch_register_area(TOUCH_AREA_STRUCT* area)
|
bool touch_register_area(TOUCH_AREA_STRUCT* area)
|
||||||
{
|
{
|
||||||
//go through pointer array and check for free space
|
//go through pointer array and check for free space
|
||||||
for (unsigned char i = 0; i < NUM_AREAS; i++) {
|
for(unsigned char i=0; i<NUM_AREAS; i++)
|
||||||
if (areas[i] == NULL) { //free space found
|
{
|
||||||
|
if(areas[i]==NULL) //free space found
|
||||||
|
{
|
||||||
area->flags=0; //we start with empty flags (PenInside=0)
|
area->flags=0; //we start with empty flags (PenInside=0)
|
||||||
areas[i]=area; //save pointer into list
|
areas[i]=area; //save pointer into list
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false; //no free space found
|
return false; //no free space found
|
||||||
}
|
}
|
||||||
|
|
||||||
void touch_unregister_area(TOUCH_AREA_STRUCT* area)
|
void touch_unregister_area(TOUCH_AREA_STRUCT* area)
|
||||||
{
|
{
|
||||||
if (area == NULL) {
|
if(area==NULL) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//go through pointer array and find the area to remove
|
//go through pointer array and find the area to remove
|
||||||
for (unsigned char i = 0; i < NUM_AREAS; i++) {
|
for(unsigned char i=0; i<NUM_AREAS; i++)
|
||||||
if (areas[i] == area) { //area found in pointer array at pos i
|
{
|
||||||
|
if(areas[i]==area) //area found in pointer array at pos i
|
||||||
|
{
|
||||||
areas[i]=NULL; //set pointer in list to NULL again
|
areas[i]=NULL; //set pointer in list to NULL again
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -208,7 +194,8 @@ void touch_unregister_area(TOUCH_AREA_STRUCT* area)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
POINT_STRUCT touch_get_last_point()
|
POINT_STRUCT touch_get_last_point() {
|
||||||
{
|
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,25 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: common/touch/touch.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-03 timolang@gmail.com 51089aa Refactored Project Structure for use with emulator
|
|
||||||
* 2015-04-27 timolang@gmail.com 259d446 Added touch support to emulator. Implemented basic touch function.
|
|
||||||
* 2015-04-27 timolang@gmail.com cf72baa Introduced a Screen (sub) module and divided app into multiple screens.
|
|
||||||
* 2015-05-02 timolang@gmail.com 3281616 Added some more touch functions. Improved pixy test. Drag the Image around!
|
|
||||||
* 2015-05-11 timolang@gmail.com a175a2f Added doxygen docu for touch module
|
|
||||||
* 2015-05-11 timolang@gmail.com 08d9fe0 More work on doxygen module structure
|
|
||||||
* 2015-05-12 timolang@gmail.com 1402598 Added doxygen stuff for button module and some minor changes to touch, screen_main and tft module.
|
|
||||||
* 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.
|
|
||||||
* 2015-06-01 timolang@gmail.com 06227da Added calibrate screen (WIP). fixed bug in emulator drawing.
|
|
||||||
* 2015-06-01 timolang@gmail.com eb573bc Finalized calibration. Fixed a bug in screen module.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#ifndef TOUCH_H
|
#ifndef TOUCH_H
|
||||||
#define TOUCH_H
|
#define TOUCH_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,77 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
|
||||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
|
||||||
<cconfiguration id="cdt.managedbuild.toolchain.gnu.cross.base.1368576398">
|
|
||||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.cross.base.1368576398" moduleId="org.eclipse.cdt.core.settings" name="Default">
|
|
||||||
<externalSettings/>
|
|
||||||
<extensions>
|
|
||||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
|
||||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
|
||||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
|
||||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
|
||||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
|
||||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
|
||||||
</extensions>
|
|
||||||
</storageModule>
|
|
||||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
|
||||||
<configuration artifactName="${ProjName}" buildProperties="" description="" id="cdt.managedbuild.toolchain.gnu.cross.base.1368576398" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
|
|
||||||
<folderInfo id="cdt.managedbuild.toolchain.gnu.cross.base.1368576398.357960121" name="/" resourcePath="">
|
|
||||||
<toolChain id="cdt.managedbuild.toolchain.gnu.cross.base.1769959713" name="Cross GCC" superClass="cdt.managedbuild.toolchain.gnu.cross.base">
|
|
||||||
<option id="cdt.managedbuild.option.gnu.cross.prefix.293575246" name="Prefix" superClass="cdt.managedbuild.option.gnu.cross.prefix"/>
|
|
||||||
<option id="cdt.managedbuild.option.gnu.cross.path.782624596" name="Path" superClass="cdt.managedbuild.option.gnu.cross.path"/>
|
|
||||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.174263624" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
|
|
||||||
<builder id="cdt.managedbuild.builder.gnu.cross.1279514893" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.builder.gnu.cross"/>
|
|
||||||
<tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.1136001261" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
|
|
||||||
<option id="gnu.c.compiler.option.include.paths.649992569" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/discoverpixy discovery/common}""/>
|
|
||||||
</option>
|
|
||||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1184220438" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
|
||||||
</tool>
|
|
||||||
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.compiler.1669992748" name="Cross G++ Compiler" superClass="cdt.managedbuild.tool.gnu.cross.cpp.compiler">
|
|
||||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.564868280" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
|
||||||
</tool>
|
|
||||||
<tool id="cdt.managedbuild.tool.gnu.cross.c.linker.1771545603" name="Cross GCC Linker" superClass="cdt.managedbuild.tool.gnu.cross.c.linker"/>
|
|
||||||
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.linker.490606250" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker">
|
|
||||||
<option id="gnu.cpp.link.option.paths.312574565" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
|
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/discoverpixy discovery/libs}""/>
|
|
||||||
</option>
|
|
||||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.648346019" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
|
|
||||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
|
||||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
|
||||||
</inputType>
|
|
||||||
</tool>
|
|
||||||
<tool id="cdt.managedbuild.tool.gnu.cross.archiver.1024233109" name="Cross GCC Archiver" superClass="cdt.managedbuild.tool.gnu.cross.archiver"/>
|
|
||||||
<tool id="cdt.managedbuild.tool.gnu.cross.assembler.1636598755" name="Cross GCC Assembler" superClass="cdt.managedbuild.tool.gnu.cross.assembler">
|
|
||||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1738279002" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
|
||||||
</tool>
|
|
||||||
</toolChain>
|
|
||||||
</folderInfo>
|
|
||||||
<sourceEntries>
|
|
||||||
<entry excluding="common" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="common"/>
|
|
||||||
</sourceEntries>
|
|
||||||
</configuration>
|
|
||||||
</storageModule>
|
|
||||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
|
||||||
</cconfiguration>
|
|
||||||
</storageModule>
|
|
||||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
|
||||||
<project id="example.null.999619443" name="example"/>
|
|
||||||
</storageModule>
|
|
||||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
|
||||||
<storageModule moduleId="refreshScope" versionNumber="2">
|
|
||||||
<configuration configurationName="Default">
|
|
||||||
<resource resourceType="PROJECT" workspacePath="/example"/>
|
|
||||||
</configuration>
|
|
||||||
</storageModule>
|
|
||||||
<storageModule moduleId="scannerConfiguration">
|
|
||||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
|
||||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.1368576398;cdt.managedbuild.toolchain.gnu.cross.base.1368576398.357960121;cdt.managedbuild.tool.gnu.cross.c.compiler.1136001261;cdt.managedbuild.tool.gnu.c.compiler.input.1184220438">
|
|
||||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
|
||||||
</scannerConfigBuildInfo>
|
|
||||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.1368576398;cdt.managedbuild.toolchain.gnu.cross.base.1368576398.357960121;cdt.managedbuild.tool.gnu.cross.cpp.compiler.1669992748;cdt.managedbuild.tool.gnu.cpp.compiler.input.564868280">
|
|
||||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
|
||||||
</scannerConfigBuildInfo>
|
|
||||||
</storageModule>
|
|
||||||
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
|
|
||||||
</cproject>
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>discoverpixy discovery</name>
|
|
||||||
<comment></comment>
|
|
||||||
<projects>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
|
||||||
<triggers>clean,full,incremental,</triggers>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
|
||||||
<triggers>full,incremental,</triggers>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
|
||||||
<nature>org.eclipse.cdt.core.ccnature</nature>
|
|
||||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
|
||||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
|
||||||
</natures>
|
|
||||||
<linkedResources>
|
|
||||||
<link>
|
|
||||||
<name>common</name>
|
|
||||||
<type>2</type>
|
|
||||||
<location>PARENT-1-PROJECT_LOC/common</location>
|
|
||||||
</link>
|
|
||||||
</linkedResources>
|
|
||||||
</projectDescription>
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<project>
|
|
||||||
<configuration id="cdt.managedbuild.toolchain.gnu.cross.base.1368576398" name="Default">
|
|
||||||
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
|
||||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
|
||||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
|
||||||
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
|
|
||||||
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="1373821771994211724" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
|
||||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
|
||||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
|
||||||
</provider>
|
|
||||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
|
||||||
</extension>
|
|
||||||
</configuration>
|
|
||||||
</project>
|
|
||||||
@@ -1,16 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: discovery/src/font.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-05-11 aaron@duckpond.ch 21fddc3 Implemented new functions
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include<stdint.h>
|
#include<stdint.h>
|
||||||
|
|
||||||
// SmallFont.c
|
// SmallFont.c
|
||||||
|
|||||||
@@ -1,16 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: discovery/src/font.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-05-11 aaron@duckpond.ch 21fddc3 Implemented new functions
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
const char small_font[1216];
|
const char small_font[1216];
|
||||||
const char big_font[3236];
|
const char big_font[3236];
|
||||||
const char seven_seg_num_font[2004];
|
const char seven_seg_num_font[2004];
|
||||||
|
|||||||
@@ -1,56 +1,38 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: discovery/src/ll_filesystem.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-05-10 timolang@gmail.com e2bce8f Added filesystem module, tests and implementation for it in emulator.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "ll_filesystem.h"
|
#include "ll_filesystem.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
bool ll_filesystem_init()
|
bool ll_filesystem_init() {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DIRECTORY_STRUCT* ll_filesystem_dir_open(const char* path)
|
DIRECTORY_STRUCT* ll_filesystem_dir_open(const char* path) {
|
||||||
{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ll_filesystem_dir_close(DIRECTORY_STRUCT* dir)
|
void ll_filesystem_dir_close(DIRECTORY_STRUCT* dir) {
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE_HANDLE* ll_filesystem_file_open(const char* filename)
|
FILE_HANDLE* ll_filesystem_file_open(const char* filename) {
|
||||||
{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ll_filesystem_file_close(FILE_HANDLE* handle)
|
void ll_filesystem_file_close(FILE_HANDLE* handle) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE_STATUS ll_filesystem_file_seek(FILE_HANDLE* handle, uint32_t offset)
|
FILE_STATUS ll_filesystem_file_seek(FILE_HANDLE* handle, uint32_t offset) {
|
||||||
{
|
|
||||||
return F_DISKERROR;
|
return F_DISKERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE_STATUS ll_filesystem_file_read(FILE_HANDLE* handle, uint8_t* buf, uint32_t size)
|
FILE_STATUS ll_filesystem_file_read(FILE_HANDLE* handle, uint8_t* buf, uint32_t size) {
|
||||||
{
|
|
||||||
return F_DISKERROR;
|
return F_DISKERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE_STATUS ll_filesystem_file_write(FILE_HANDLE* handle, uint8_t* buf, uint32_t size)
|
FILE_STATUS ll_filesystem_file_write(FILE_HANDLE* handle, uint8_t* buf, uint32_t size) {
|
||||||
{
|
|
||||||
return F_DISKERROR;
|
return F_DISKERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: discovery/src/ll_system.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-03 timolang@gmail.com 9a1d12a Refactored discovery, to use new project structure. Almost ready.
|
|
||||||
* 2015-04-25 timolang@gmail.com 3d1e4b2 Simplified code a bit. Emulator does not work stable when replugging pixy.
|
|
||||||
* 2015-04-25 timolang@gmail.com 0858b0d Fixed some bugs when receiving large data.
|
|
||||||
* 2015-04-27 aaron@duckpond.ch 0b61f21 Fixed misplacement of prototypes in ll_tft.h and implemented a propper init function.
|
|
||||||
* 2015-06-02 timolang@gmail.com 16bfdad Removed conflicting led usage from usb code.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "ll_system.h"
|
#include "ll_system.h"
|
||||||
#include "stm32f4xx.h"
|
#include "stm32f4xx.h"
|
||||||
#include "stm32f4_discovery.h"
|
#include "stm32f4_discovery.h"
|
||||||
@@ -64,17 +47,14 @@ bool ll_system_init(void)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ll_system_process()
|
void ll_system_process() {
|
||||||
{
|
|
||||||
USBH_Process(&USB_OTG_Core, &USB_Host);
|
USBH_Process(&USB_OTG_Core, &USB_Host);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ll_system_delay(uint32_t msec)
|
void ll_system_delay(uint32_t msec) {
|
||||||
{
|
|
||||||
USB_OTG_BSP_mDelay(msec);
|
USB_OTG_BSP_mDelay(msec);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ll_system_toggle_led()
|
void ll_system_toggle_led() {
|
||||||
{
|
|
||||||
//no led's free :(
|
//no led's free :(
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: discovery/src/ll_tft.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-03 timolang@gmail.com 9a1d12a Refactored discovery, to use new project structure. Almost ready.
|
|
||||||
* 2015-04-03 timolang@gmail.com 1aa9194 Fixed Drawing of rects in Emulator. Got frames from pixy to emulator. Slooooow.
|
|
||||||
* 2015-04-27 aaron@duckpond.ch aed90ef Drawcircle added (emulator)
|
|
||||||
* 2015-04-27 timolang@gmail.com e249fb2 Added font support
|
|
||||||
* 2015-04-27 aaron@duckpond.ch f0a6c3b Implemented init functions for gpio, fsmc and display
|
|
||||||
* 2015-04-27 aaron@duckpond.ch 0b61f21 Fixed misplacement of prototypes in ll_tft.h and implemented a propper init function.
|
|
||||||
* 2015-04-28 aaron@duckpond.ch a413591 Implemented ll_tft_fill_rectange and ll_tft_set_window
|
|
||||||
* 2015-05-04 aaron@duckpond.ch c224d40 Changed display init
|
|
||||||
* 2015-05-11 aaron@duckpond.ch 21fddc3 Implemented new functions
|
|
||||||
* 2015-05-12 aaron@duckpond.ch aec62d4 Added datasheets, updated touchsupport.
|
|
||||||
* 2015-06-01 aaron@duckpond.ch caa7b5c Added IRQ for user button, fixed some touchproblems.
|
|
||||||
* 2015-06-01 timolang@gmail.com 60c2895 Fixed lowlevel tft discovery functions for draw_char and fill_rect.
|
|
||||||
* 2015-06-02 timolang@gmail.com da34bce Fixed all printf related problems on discovery using workarounds and newlib nano-instead of newlib
|
|
||||||
* 2015-06-06 aaron@duckpond.ch a04cda9 Refactured comments and implemented a bugfix for the PID controller
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
/* TFT lowlevel functions
|
/* TFT lowlevel functions
|
||||||
*
|
*
|
||||||
* Pinout:
|
* Pinout:
|
||||||
@@ -68,8 +42,7 @@ static void tft_set_backlight(bool state);
|
|||||||
static void tft_reset(bool state);
|
static void tft_reset(bool state);
|
||||||
static void tft_write_reg(uint8_t reg_adr, uint16_t reg_value);
|
static void tft_write_reg(uint8_t reg_adr, uint16_t reg_value);
|
||||||
static uint16_t tft_read_reg(uint8_t reg_adr);
|
static uint16_t tft_read_reg(uint8_t reg_adr);
|
||||||
static void tft_set_window(uint16_t xstart, uint16_t ystart, uint16_t xend, uint16_t yend);
|
static void tft_set_window(uint16_t xstart, uint16_t ystart, uint16_t xend, uint16_t yend);void tft_reset_window();
|
||||||
void tft_reset_window();
|
|
||||||
|
|
||||||
/* draw functions */
|
/* draw functions */
|
||||||
void ll_tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
|
void ll_tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
|
||||||
@@ -451,38 +424,53 @@ void tft_reset_window()
|
|||||||
// Draw a line on the given coordinates
|
// Draw a line on the given coordinates
|
||||||
void ll_tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
|
void ll_tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
|
||||||
{
|
{
|
||||||
if (abs(x2 - x1) > abs(y2 - y1)) { //line has more distance in x than y => iterate over x distance
|
if(abs(x2-x1) > abs(y2-y1)) //line has more distance in x than y => iterate over x distance
|
||||||
|
{
|
||||||
//Without floating point!
|
//Without floating point!
|
||||||
int deltax = ((int)x2-(int)x1);
|
int deltax = ((int)x2-(int)x1);
|
||||||
int deltay = ((int)y2-(int)y1)<<1;
|
int deltay = ((int)y2-(int)y1)<<1;
|
||||||
int x = 0;
|
int x = 0;
|
||||||
|
if (x1>x2)
|
||||||
if (x1 > x2) {
|
{
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
tft_set_cursor(x1+x,y1+ (((long)deltay*(long)x/deltax+1)>>1));
|
tft_set_cursor(x1+x,y1+ (((long)deltay*(long)x/deltax+1)>>1));
|
||||||
TFT_RAM = color;
|
TFT_RAM = color;
|
||||||
} while (x-- != deltax);
|
|
||||||
} else {
|
|
||||||
do {
|
|
||||||
tft_set_cursor(x1 + x, y1 + (((long)deltay * (long)x / deltax + 1) >> 1));
|
|
||||||
TFT_RAM = color;
|
|
||||||
} while (x++ != deltax);
|
|
||||||
}
|
}
|
||||||
} else { // => iterate over y distance
|
while(x--!=deltax);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
tft_set_cursor(x1+x,y1+ (((long)deltay*(long)x/deltax+1)>>1));
|
||||||
|
TFT_RAM = color;
|
||||||
|
}
|
||||||
|
while(x++!=deltax);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // => iterate over y distance
|
||||||
|
{
|
||||||
int deltax = ((int)x2-(int)x1)<<1;
|
int deltax = ((int)x2-(int)x1)<<1;
|
||||||
int deltay = ((int)y2-(int)y1);
|
int deltay = ((int)y2-(int)y1);
|
||||||
int y = 0;
|
int y = 0;
|
||||||
|
if (y1>y2)
|
||||||
if (y1 > y2) {
|
{
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
tft_set_cursor(x1+ (((long)deltax*(long)y/deltay+1)>>1),y1+ y);
|
tft_set_cursor(x1+ (((long)deltax*(long)y/deltay+1)>>1),y1+ y);
|
||||||
TFT_RAM = color;
|
TFT_RAM = color;
|
||||||
} while (y-- != deltay);
|
}
|
||||||
} else {
|
while(y--!=deltay);
|
||||||
do {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
tft_set_cursor(x1+ (((long)deltax*(long)y/deltay+1)>>1),y1+ y);
|
tft_set_cursor(x1+ (((long)deltax*(long)y/deltay+1)>>1),y1+ y);
|
||||||
TFT_RAM = color;
|
TFT_RAM = color;
|
||||||
} while (y++ != deltay);
|
}
|
||||||
|
while(y++!=deltay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -515,16 +503,9 @@ void ll_tft_draw_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, u
|
|||||||
i = x1;
|
i = x1;
|
||||||
//Drawing the two horizontal lines
|
//Drawing the two horizontal lines
|
||||||
tft_set_cursor(x1, y1);
|
tft_set_cursor(x1, y1);
|
||||||
|
while(i++ != x2) TFT_RAM = color;
|
||||||
while (i++ != x2) {
|
|
||||||
TFT_RAM = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
tft_set_cursor(x1,y2);
|
tft_set_cursor(x1,y2);
|
||||||
|
while(i-- != x1) TFT_RAM = color;
|
||||||
while (i-- != x1) {
|
|
||||||
TFT_RAM = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -593,14 +574,9 @@ void ll_tft_draw_circle(uint16_t x, uint16_t y, uint16_t r, uint16_t color)
|
|||||||
static const char *get_font(uint8_t font)
|
static const char *get_font(uint8_t font)
|
||||||
{
|
{
|
||||||
switch(font){
|
switch(font){
|
||||||
case 0:
|
case 0: return small_font;
|
||||||
return small_font;
|
case 1: return big_font;
|
||||||
|
case 2: return seven_seg_num_font;
|
||||||
case 1:
|
|
||||||
return big_font;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
return seven_seg_num_font;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -645,7 +621,6 @@ void ll_tft_draw_char(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor,
|
|||||||
if(bgIsTrans) {
|
if(bgIsTrans) {
|
||||||
tft_set_cursor(x+xadd,y+yadd);
|
tft_set_cursor(x+xadd,y+yadd);
|
||||||
}
|
}
|
||||||
|
|
||||||
TFT_RAM = color;
|
TFT_RAM = color;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -654,10 +629,11 @@ void ll_tft_draw_char(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bgIsTrans) {
|
if(bgIsTrans)
|
||||||
|
{
|
||||||
xadd++;
|
xadd++;
|
||||||
|
if(xadd==width)
|
||||||
if (xadd == width) {
|
{
|
||||||
xadd=0;
|
xadd=0;
|
||||||
yadd++;
|
yadd++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: discovery/src/ll_touch.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-27 timolang@gmail.com 259d446 Added touch support to emulator. Implemented basic touch function.
|
|
||||||
* 2015-05-12 aaron@duckpond.ch 3b2ef30 Added PID source code and Pinmap
|
|
||||||
* 2015-05-12 aaron@duckpond.ch 5e374f4 Added datasheet and touch template
|
|
||||||
* 2015-05-12 aaron@duckpond.ch aec62d4 Added datasheets, updated touchsupport.
|
|
||||||
* 2015-05-13 aaron@duckpond.ch 1396d24 Working touchcontroller communication
|
|
||||||
* 2015-05-28 aaron@duckpond.ch 5bda699 implemented functions to get x and y coordinates and a test function
|
|
||||||
* 2015-05-28 aaron@duckpond.ch 9b1020c Working PENIRQ
|
|
||||||
* 2015-05-28 aaron@duckpond.ch 30197bf recent changes
|
|
||||||
* 2015-05-29 aaron@duckpond.ch 7d2d1a1 Implemented basic sampling and averaging of touch coordinates using timer7
|
|
||||||
* 2015-06-01 aaron@duckpond.ch dff2e76 Touch recognition working
|
|
||||||
* 2015-06-01 aaron@duckpond.ch caa7b5c Added IRQ for user button, fixed some touchproblems.
|
|
||||||
* 2015-06-01 timolang@gmail.com eb573bc Finalized calibration. Fixed a bug in screen module.
|
|
||||||
* 2015-06-03 timolang@gmail.com 74aa186 Made pixy_test screen working again. Had to disable pixy_service. Recalibrated initial touch values.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "ll_touch.h"
|
#include "ll_touch.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "screen_calibrate.h"
|
#include "screen_calibrate.h"
|
||||||
@@ -106,11 +81,8 @@ static uint16_t touch_get_y_coord()
|
|||||||
static uint8_t touch_send(uint8_t dat)
|
static uint8_t touch_send(uint8_t dat)
|
||||||
{
|
{
|
||||||
SPI_I2S_SendData(SPI2, dat);
|
SPI_I2S_SendData(SPI2, dat);
|
||||||
|
|
||||||
while(SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_BSY) != RESET);
|
while(SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_BSY) != RESET);
|
||||||
|
|
||||||
while(SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_RXNE) == RESET);
|
while(SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_RXNE) == RESET);
|
||||||
|
|
||||||
return SPI_I2S_ReceiveData(SPI2);
|
return SPI_I2S_ReceiveData(SPI2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +1,11 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: discovery/src/main.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-03 timolang@gmail.com 21dd1e2 Starting to integrate usb branch. Optimized Makefiles
|
|
||||||
* 2015-04-03 timolang@gmail.com 9a1d12a Refactored discovery, to use new project structure. Almost ready.
|
|
||||||
* 2015-04-25 timolang@gmail.com 416883c Pixy&Usb work with the new folder structure now.
|
|
||||||
* 2015-04-25 timolang@gmail.com 3d1e4b2 Simplified code a bit. Emulator does not work stable when replugging pixy.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
app_init();
|
app_init();
|
||||||
|
|
||||||
while (1) {
|
while (1)
|
||||||
|
{
|
||||||
app_process();
|
app_process();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: discovery/src/newlib_stubs.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-03 timolang@gmail.com 21dd1e2 Starting to integrate usb branch. Optimized Makefiles
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* newlib_stubs.c
|
* newlib_stubs.c
|
||||||
*
|
*
|
||||||
@@ -50,25 +37,21 @@ char** environ = __env;
|
|||||||
|
|
||||||
int _write(int file, char *ptr, int len);
|
int _write(int file, char *ptr, int len);
|
||||||
|
|
||||||
void _exit(int status)
|
void _exit(int status) {
|
||||||
{
|
|
||||||
_write(1, "exit", 4);
|
_write(1, "exit", 4);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int _close(int file)
|
int _close(int file) {
|
||||||
{
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
execve
|
execve
|
||||||
Transfer control to a new process. Minimal implementation (for a system without processes):
|
Transfer control to a new process. Minimal implementation (for a system without processes):
|
||||||
*/
|
*/
|
||||||
int _execve(char* name, char** argv, char** env)
|
int _execve(char *name, char **argv, char **env) {
|
||||||
{
|
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -77,8 +60,7 @@ int _execve(char* name, char** argv, char** env)
|
|||||||
Create a new process. Minimal implementation (for a system without processes):
|
Create a new process. Minimal implementation (for a system without processes):
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int _fork()
|
int _fork() {
|
||||||
{
|
|
||||||
errno = EAGAIN;
|
errno = EAGAIN;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -88,8 +70,7 @@ int _fork()
|
|||||||
all files are regarded as character special devices.
|
all files are regarded as character special devices.
|
||||||
The `sys/stat.h' header file required is distributed in the `include' subdirectory for this C library.
|
The `sys/stat.h' header file required is distributed in the `include' subdirectory for this C library.
|
||||||
*/
|
*/
|
||||||
int _fstat(int file, struct stat* st)
|
int _fstat(int file, struct stat *st) {
|
||||||
{
|
|
||||||
st->st_mode = S_IFCHR;
|
st->st_mode = S_IFCHR;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -99,8 +80,7 @@ int _fstat(int file, struct stat* st)
|
|||||||
Process-ID; this is sometimes used to generate strings unlikely to conflict with other processes. Minimal implementation, for a system without processes:
|
Process-ID; this is sometimes used to generate strings unlikely to conflict with other processes. Minimal implementation, for a system without processes:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int _getpid()
|
int _getpid() {
|
||||||
{
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,14 +88,12 @@ int _getpid()
|
|||||||
isatty
|
isatty
|
||||||
Query whether output stream is a terminal. For consistency with the other minimal implementations,
|
Query whether output stream is a terminal. For consistency with the other minimal implementations,
|
||||||
*/
|
*/
|
||||||
int _isatty(int file)
|
int _isatty(int file) {
|
||||||
{
|
|
||||||
switch (file){
|
switch (file){
|
||||||
case STDOUT_FILENO:
|
case STDOUT_FILENO:
|
||||||
case STDERR_FILENO:
|
case STDERR_FILENO:
|
||||||
case STDIN_FILENO:
|
case STDIN_FILENO:
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
//errno = ENOTTY;
|
//errno = ENOTTY;
|
||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
@@ -128,8 +106,7 @@ int _isatty(int file)
|
|||||||
kill
|
kill
|
||||||
Send a signal. Minimal implementation:
|
Send a signal. Minimal implementation:
|
||||||
*/
|
*/
|
||||||
int _kill(int pid, int sig)
|
int _kill(int pid, int sig) {
|
||||||
{
|
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@@ -139,8 +116,7 @@ int _kill(int pid, int sig)
|
|||||||
Establish a new name for an existing file. Minimal implementation:
|
Establish a new name for an existing file. Minimal implementation:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int _link(char* old, char* new)
|
int _link(char *old, char *new) {
|
||||||
{
|
|
||||||
errno = EMLINK;
|
errno = EMLINK;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -149,8 +125,7 @@ int _link(char* old, char* new)
|
|||||||
lseek
|
lseek
|
||||||
Set position in a file. Minimal implementation:
|
Set position in a file. Minimal implementation:
|
||||||
*/
|
*/
|
||||||
int _lseek(int file, int ptr, int dir)
|
int _lseek(int file, int ptr, int dir) {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,8 +134,7 @@ int _lseek(int file, int ptr, int dir)
|
|||||||
Increase program data space.
|
Increase program data space.
|
||||||
Malloc and related functions depend on this
|
Malloc and related functions depend on this
|
||||||
*/
|
*/
|
||||||
caddr_t _sbrk(int incr)
|
caddr_t _sbrk(int incr) {
|
||||||
{
|
|
||||||
|
|
||||||
extern char _ebss; // Defined by the linker
|
extern char _ebss; // Defined by the linker
|
||||||
static char *heap_end;
|
static char *heap_end;
|
||||||
@@ -169,12 +143,11 @@ caddr_t _sbrk(int incr)
|
|||||||
if (heap_end == 0) {
|
if (heap_end == 0) {
|
||||||
heap_end = &_ebss;
|
heap_end = &_ebss;
|
||||||
}
|
}
|
||||||
|
|
||||||
prev_heap_end = heap_end;
|
prev_heap_end = heap_end;
|
||||||
|
|
||||||
char * stack = (char*) __get_MSP();
|
char * stack = (char*) __get_MSP();
|
||||||
|
if (heap_end + incr > stack)
|
||||||
if (heap_end + incr > stack) {
|
{
|
||||||
_write (STDERR_FILENO, "Heap and stack collision\n", 25);
|
_write (STDERR_FILENO, "Heap and stack collision\n", 25);
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return (caddr_t) -1;
|
return (caddr_t) -1;
|
||||||
@@ -201,11 +174,9 @@ int _open(char* path, int flags, ...)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
int _read(int file, char* ptr, int len)
|
int _read(int file, char *ptr, int len) {
|
||||||
{
|
|
||||||
int n;
|
int n;
|
||||||
int num = 0;
|
int num = 0;
|
||||||
|
|
||||||
switch (file) {
|
switch (file) {
|
||||||
/*case STDIN_FILENO:
|
/*case STDIN_FILENO:
|
||||||
for (n = 0; n < len; n++) {
|
for (n = 0; n < len; n++) {
|
||||||
@@ -227,7 +198,6 @@ int _read(int file, char* ptr, int len)
|
|||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,8 +207,7 @@ int _read(int file, char* ptr, int len)
|
|||||||
int _EXFUN(stat,( const char *__path, struct stat *__sbuf ));
|
int _EXFUN(stat,( const char *__path, struct stat *__sbuf ));
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int _stat(const char* filepath, struct stat* st)
|
int _stat(const char *filepath, struct stat *st) {
|
||||||
{
|
|
||||||
st->st_mode = S_IFCHR;
|
st->st_mode = S_IFCHR;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -248,8 +217,7 @@ int _stat(const char* filepath, struct stat* st)
|
|||||||
Timing information for current process. Minimal implementation:
|
Timing information for current process. Minimal implementation:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
clock_t _times(struct tms* buf)
|
clock_t _times(struct tms *buf) {
|
||||||
{
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,8 +225,7 @@ clock_t _times(struct tms* buf)
|
|||||||
unlink
|
unlink
|
||||||
Remove a file's directory entry. Minimal implementation:
|
Remove a file's directory entry. Minimal implementation:
|
||||||
*/
|
*/
|
||||||
int _unlink(char* name)
|
int _unlink(char *name) {
|
||||||
{
|
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -267,8 +234,7 @@ int _unlink(char* name)
|
|||||||
wait
|
wait
|
||||||
Wait for a child process. Minimal implementation:
|
Wait for a child process. Minimal implementation:
|
||||||
*/
|
*/
|
||||||
int _wait(int* status)
|
int _wait(int *status) {
|
||||||
{
|
|
||||||
errno = ECHILD;
|
errno = ECHILD;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -278,61 +244,42 @@ int _wait(int* status)
|
|||||||
Write a character to a file. `libc' subroutines will use this system routine for output to all files, including stdout
|
Write a character to a file. `libc' subroutines will use this system routine for output to all files, including stdout
|
||||||
Returns -1 on error or number of bytes sent
|
Returns -1 on error or number of bytes sent
|
||||||
*/
|
*/
|
||||||
int _write(int file, char* ptr, int len)
|
int _write(int file, char *ptr, int len) {
|
||||||
{
|
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
switch (file) {
|
switch (file) {
|
||||||
case STDOUT_FILENO: /*stdout*/
|
case STDOUT_FILENO: /*stdout*/
|
||||||
for (n = 0; n < len; n++) {
|
for (n = 0; n < len; n++) {
|
||||||
#if STDOUT_USART == 1
|
#if STDOUT_USART == 1
|
||||||
|
|
||||||
while ((USART1->SR & USART_FLAG_TC) == (uint16_t)RESET) {}
|
while ((USART1->SR & USART_FLAG_TC) == (uint16_t)RESET) {}
|
||||||
|
|
||||||
USART1->DR = (*ptr++ & (uint16_t)0x01FF);
|
USART1->DR = (*ptr++ & (uint16_t)0x01FF);
|
||||||
#elif STDOUT_USART == 2
|
#elif STDOUT_USART == 2
|
||||||
|
|
||||||
while ((USART2->SR & USART_FLAG_TC) == (uint16_t) RESET) {
|
while ((USART2->SR & USART_FLAG_TC) == (uint16_t) RESET) {
|
||||||
}
|
}
|
||||||
|
|
||||||
USART2->DR = (*ptr++ & (uint16_t) 0x01FF);
|
USART2->DR = (*ptr++ & (uint16_t) 0x01FF);
|
||||||
#elif STDOUT_USART == 3
|
#elif STDOUT_USART == 3
|
||||||
|
|
||||||
while ((USART3->SR & USART_FLAG_TC) == (uint16_t)RESET) {}
|
while ((USART3->SR & USART_FLAG_TC) == (uint16_t)RESET) {}
|
||||||
|
|
||||||
USART3->DR = (*ptr++ & (uint16_t)0x01FF);
|
USART3->DR = (*ptr++ & (uint16_t)0x01FF);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STDERR_FILENO: /* stderr */
|
case STDERR_FILENO: /* stderr */
|
||||||
for (n = 0; n < len; n++) {
|
for (n = 0; n < len; n++) {
|
||||||
#if STDERR_USART == 1
|
#if STDERR_USART == 1
|
||||||
|
|
||||||
while ((USART1->SR & USART_FLAG_TC) == (uint16_t)RESET) {}
|
while ((USART1->SR & USART_FLAG_TC) == (uint16_t)RESET) {}
|
||||||
|
|
||||||
USART1->DR = (*ptr++ & (uint16_t)0x01FF);
|
USART1->DR = (*ptr++ & (uint16_t)0x01FF);
|
||||||
#elif STDERR_USART == 2
|
#elif STDERR_USART == 2
|
||||||
|
|
||||||
while ((USART2->SR & USART_FLAG_TC) == (uint16_t) RESET) {
|
while ((USART2->SR & USART_FLAG_TC) == (uint16_t) RESET) {
|
||||||
}
|
}
|
||||||
|
|
||||||
USART2->DR = (*ptr++ & (uint16_t) 0x01FF);
|
USART2->DR = (*ptr++ & (uint16_t) 0x01FF);
|
||||||
#elif STDERR_USART == 3
|
#elif STDERR_USART == 3
|
||||||
|
|
||||||
while ((USART3->SR & USART_FLAG_TC) == (uint16_t)RESET) {}
|
while ((USART3->SR & USART_FLAG_TC) == (uint16_t)RESET) {}
|
||||||
|
|
||||||
USART3->DR = (*ptr++ & (uint16_t)0x01FF);
|
USART3->DR = (*ptr++ & (uint16_t)0x01FF);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: discovery/src/system_stm32f4xx.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-03 timolang@gmail.com 21dd1e2 Starting to integrate usb branch. Optimized Makefiles
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
* @file system_stm32f4xx.c
|
* @file system_stm32f4xx.c
|
||||||
@@ -294,15 +281,14 @@ void SystemCoreClockUpdate(void)
|
|||||||
/* Get SYSCLK source -------------------------------------------------------*/
|
/* Get SYSCLK source -------------------------------------------------------*/
|
||||||
tmp = RCC->CFGR & RCC_CFGR_SWS;
|
tmp = RCC->CFGR & RCC_CFGR_SWS;
|
||||||
|
|
||||||
switch (tmp) {
|
switch (tmp)
|
||||||
|
{
|
||||||
case 0x00: /* HSI used as system clock source */
|
case 0x00: /* HSI used as system clock source */
|
||||||
SystemCoreClock = HSI_VALUE;
|
SystemCoreClock = HSI_VALUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x04: /* HSE used as system clock source */
|
case 0x04: /* HSE used as system clock source */
|
||||||
SystemCoreClock = HSE_VALUE;
|
SystemCoreClock = HSE_VALUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x08: /* PLL used as system clock source */
|
case 0x08: /* PLL used as system clock source */
|
||||||
|
|
||||||
/* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
|
/* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
|
||||||
@@ -311,10 +297,13 @@ void SystemCoreClockUpdate(void)
|
|||||||
pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
|
pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
|
||||||
pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
|
pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
|
||||||
|
|
||||||
if (pllsource != 0) {
|
if (pllsource != 0)
|
||||||
|
{
|
||||||
/* HSE used as PLL clock source */
|
/* HSE used as PLL clock source */
|
||||||
pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
|
pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
/* HSI used as PLL clock source */
|
/* HSI used as PLL clock source */
|
||||||
pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
|
pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
|
||||||
}
|
}
|
||||||
@@ -322,12 +311,10 @@ void SystemCoreClockUpdate(void)
|
|||||||
pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2;
|
pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2;
|
||||||
SystemCoreClock = pllvco/pllp;
|
SystemCoreClock = pllvco/pllp;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
SystemCoreClock = HSI_VALUE;
|
SystemCoreClock = HSI_VALUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compute HCLK frequency --------------------------------------------------*/
|
/* Compute HCLK frequency --------------------------------------------------*/
|
||||||
/* Get HCLK prescaler */
|
/* Get HCLK prescaler */
|
||||||
tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
|
tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
|
||||||
@@ -354,18 +341,23 @@ static void SetSysClock(void)
|
|||||||
RCC->CR |= ((uint32_t)RCC_CR_HSEON);
|
RCC->CR |= ((uint32_t)RCC_CR_HSEON);
|
||||||
|
|
||||||
/* Wait till HSE is ready and if Time out is reached exit */
|
/* Wait till HSE is ready and if Time out is reached exit */
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
HSEStatus = RCC->CR & RCC_CR_HSERDY;
|
HSEStatus = RCC->CR & RCC_CR_HSERDY;
|
||||||
StartUpCounter++;
|
StartUpCounter++;
|
||||||
} while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
|
} while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));
|
||||||
|
|
||||||
if ((RCC->CR & RCC_CR_HSERDY) != RESET) {
|
if ((RCC->CR & RCC_CR_HSERDY) != RESET)
|
||||||
|
{
|
||||||
HSEStatus = (uint32_t)0x01;
|
HSEStatus = (uint32_t)0x01;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
HSEStatus = (uint32_t)0x00;
|
HSEStatus = (uint32_t)0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HSEStatus == (uint32_t)0x01) {
|
if (HSEStatus == (uint32_t)0x01)
|
||||||
|
{
|
||||||
/* Enable high performance mode, System frequency up to 168 MHz */
|
/* Enable high performance mode, System frequency up to 168 MHz */
|
||||||
RCC->APB1ENR |= RCC_APB1ENR_PWREN;
|
RCC->APB1ENR |= RCC_APB1ENR_PWREN;
|
||||||
PWR->CR |= PWR_CR_PMODE;
|
PWR->CR |= PWR_CR_PMODE;
|
||||||
@@ -387,7 +379,8 @@ static void SetSysClock(void)
|
|||||||
RCC->CR |= RCC_CR_PLLON;
|
RCC->CR |= RCC_CR_PLLON;
|
||||||
|
|
||||||
/* Wait till the main PLL is ready */
|
/* Wait till the main PLL is ready */
|
||||||
while ((RCC->CR & RCC_CR_PLLRDY) == 0) {
|
while((RCC->CR & RCC_CR_PLLRDY) == 0)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Configure Flash prefetch, Instruction cache, Data cache and wait state */
|
/* Configure Flash prefetch, Instruction cache, Data cache and wait state */
|
||||||
@@ -399,11 +392,11 @@ static void SetSysClock(void)
|
|||||||
|
|
||||||
/* Wait till the main PLL is used as system clock source */
|
/* Wait till the main PLL is used as system clock source */
|
||||||
while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS ) != RCC_CFGR_SWS_PLL);
|
while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS ) != RCC_CFGR_SWS_PLL);
|
||||||
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
/* If HSE fails to start-up, the application will have wrong clock
|
else
|
||||||
|
{ /* If HSE fails to start-up, the application will have wrong clock
|
||||||
configuration. User can add here some code to deal with this error */
|
configuration. User can add here some code to deal with this error */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -549,3 +542,4 @@ void SystemInit_ExtMemCtl(void)
|
|||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: discovery/src/usb_bsp.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-03 timolang@gmail.com 21dd1e2 Starting to integrate usb branch. Optimized Makefiles
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "usb_bsp.h"
|
#include "usb_bsp.h"
|
||||||
@@ -269,10 +256,13 @@ void USB_OTG_BSP_DriveVBUS(USB_OTG_CORE_HANDLE* pdev, uint8_t state)
|
|||||||
The application uses this field to control power to this port, and the core
|
The application uses this field to control power to this port, and the core
|
||||||
clears this bit on an overcurrent condition.
|
clears this bit on an overcurrent condition.
|
||||||
*/
|
*/
|
||||||
if (0 == state) {
|
if (0 == state)
|
||||||
|
{
|
||||||
/* DISABLE is needed on output of the Power Switch */
|
/* DISABLE is needed on output of the Power Switch */
|
||||||
GPIO_SetBits(HOST_POWERSW_PORT, HOST_POWERSW_VBUS);
|
GPIO_SetBits(HOST_POWERSW_PORT, HOST_POWERSW_VBUS);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
/*ENABLE the Power Switch by driving the Enable LOW */
|
/*ENABLE the Power Switch by driving the Enable LOW */
|
||||||
GPIO_ResetBits(HOST_POWERSW_PORT, HOST_POWERSW_VBUS);
|
GPIO_ResetBits(HOST_POWERSW_PORT, HOST_POWERSW_VBUS);
|
||||||
}
|
}
|
||||||
@@ -352,13 +342,14 @@ void USB_OTG_BSP_uDelay(const uint32_t usec)
|
|||||||
#else
|
#else
|
||||||
__IO uint32_t count = 0;
|
__IO uint32_t count = 0;
|
||||||
const uint32_t utime = (120 * usec / 7);
|
const uint32_t utime = (120 * usec / 7);
|
||||||
|
do
|
||||||
do {
|
{
|
||||||
if (++count > utime) {
|
if ( ++count > utime )
|
||||||
|
{
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
} while (1);
|
}
|
||||||
|
while (1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -388,17 +379,18 @@ void USB_OTG_BSP_mDelay(const uint32_t msec)
|
|||||||
void USB_OTG_BSP_TimerIRQ (void)
|
void USB_OTG_BSP_TimerIRQ (void)
|
||||||
{
|
{
|
||||||
#ifdef USE_ACCURATE_TIME
|
#ifdef USE_ACCURATE_TIME
|
||||||
|
if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET)
|
||||||
if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET) {
|
{
|
||||||
TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
|
TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
|
||||||
|
if (BSP_delay > 0x00)
|
||||||
if (BSP_delay > 0x00) {
|
{
|
||||||
BSP_delay--;
|
BSP_delay--;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
TIM_Cmd(TIM2, DISABLE);
|
TIM_Cmd(TIM2, DISABLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,9 +408,7 @@ static void BSP_Delay(uint32_t nTime, uint8_t unit)
|
|||||||
|
|
||||||
BSP_delay = nTime;
|
BSP_delay = nTime;
|
||||||
BSP_SetTime(unit);
|
BSP_SetTime(unit);
|
||||||
|
|
||||||
while (BSP_delay != 0);
|
while (BSP_delay != 0);
|
||||||
|
|
||||||
TIM_Cmd(TIM2, DISABLE);
|
TIM_Cmd(TIM2, DISABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -436,12 +426,14 @@ static void BSP_SetTime(uint8_t unit)
|
|||||||
TIM_ITConfig(TIM2, TIM_IT_Update, DISABLE);
|
TIM_ITConfig(TIM2, TIM_IT_Update, DISABLE);
|
||||||
|
|
||||||
|
|
||||||
if (unit == TIM_USEC_DELAY) {
|
if (unit == TIM_USEC_DELAY)
|
||||||
|
{
|
||||||
TIM_TimeBaseStructure.TIM_Period = 11;
|
TIM_TimeBaseStructure.TIM_Period = 11;
|
||||||
} else if (unit == TIM_MSEC_DELAY) {
|
}
|
||||||
|
else if (unit == TIM_MSEC_DELAY)
|
||||||
|
{
|
||||||
TIM_TimeBaseStructure.TIM_Period = 11999;
|
TIM_TimeBaseStructure.TIM_Period = 11999;
|
||||||
}
|
}
|
||||||
|
|
||||||
TIM_TimeBaseStructure.TIM_Prescaler = 5;
|
TIM_TimeBaseStructure.TIM_Prescaler = 5;
|
||||||
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
|
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
|
||||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
||||||
|
|||||||
@@ -1,18 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: discovery/src/usbh_msc_core.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-03 timolang@gmail.com 21dd1e2 Starting to integrate usb branch. Optimized Makefiles
|
|
||||||
* 2015-04-25 timolang@gmail.com 416883c Pixy&Usb work with the new folder structure now.
|
|
||||||
* 2015-04-25 timolang@gmail.com 3d1e4b2 Simplified code a bit. Emulator does not work stable when replugging pixy.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
#include "usbh_msc_core.h"
|
#include "usbh_msc_core.h"
|
||||||
#include "usbh_core.h"
|
#include "usbh_core.h"
|
||||||
@@ -36,7 +21,8 @@ extern USBH_HOST USB_Host;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
USBH_Class_cb_TypeDef USBH_MSC_cb = {
|
USBH_Class_cb_TypeDef USBH_MSC_cb =
|
||||||
|
{
|
||||||
USBH_MSC_InterfaceInit,
|
USBH_MSC_InterfaceInit,
|
||||||
USBH_MSC_InterfaceDeInit,
|
USBH_MSC_InterfaceDeInit,
|
||||||
USBH_MSC_ClassRequest,
|
USBH_MSC_ClassRequest,
|
||||||
@@ -44,7 +30,8 @@ USBH_Class_cb_TypeDef USBH_MSC_cb = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
uint8_t hc_num_in;
|
uint8_t hc_num_in;
|
||||||
uint8_t hc_num_out;
|
uint8_t hc_num_out;
|
||||||
uint8_t MSBulkOutEp;
|
uint8_t MSBulkOutEp;
|
||||||
@@ -65,19 +52,26 @@ static USBH_Status USBH_MSC_InterfaceInit(USB_OTG_CORE_HANDLE* pdev,
|
|||||||
|
|
||||||
if((pphost->device_prop.Itf_Desc[1].bInterfaceClass == 255) &&
|
if((pphost->device_prop.Itf_Desc[1].bInterfaceClass == 255) &&
|
||||||
(pphost->device_prop.Itf_Desc[1].bInterfaceProtocol == 0) &&
|
(pphost->device_prop.Itf_Desc[1].bInterfaceProtocol == 0) &&
|
||||||
(pphost->device_prop.Itf_Desc[1].bInterfaceSubClass == 1)) {
|
(pphost->device_prop.Itf_Desc[1].bInterfaceSubClass == 1))
|
||||||
if (pphost->device_prop.Ep_Desc[0][0].bEndpointAddress & 0x80) {
|
{
|
||||||
|
if(pphost->device_prop.Ep_Desc[0][0].bEndpointAddress & 0x80)
|
||||||
|
{
|
||||||
MSC_Machine.MSBulkInEp = (pphost->device_prop.Ep_Desc[0][0].bEndpointAddress);
|
MSC_Machine.MSBulkInEp = (pphost->device_prop.Ep_Desc[0][0].bEndpointAddress);
|
||||||
MSC_Machine.MSBulkInEpSize = pphost->device_prop.Ep_Desc[0][0].wMaxPacketSize;
|
MSC_Machine.MSBulkInEpSize = pphost->device_prop.Ep_Desc[0][0].wMaxPacketSize;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
MSC_Machine.MSBulkOutEp = (pphost->device_prop.Ep_Desc[0][0].bEndpointAddress);
|
MSC_Machine.MSBulkOutEp = (pphost->device_prop.Ep_Desc[0][0].bEndpointAddress);
|
||||||
MSC_Machine.MSBulkOutEpSize = pphost->device_prop.Ep_Desc[0][0].wMaxPacketSize;
|
MSC_Machine.MSBulkOutEpSize = pphost->device_prop.Ep_Desc[0][0].wMaxPacketSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pphost->device_prop.Ep_Desc[0][1].bEndpointAddress & 0x80) {
|
if(pphost->device_prop.Ep_Desc[0][1].bEndpointAddress & 0x80)
|
||||||
|
{
|
||||||
MSC_Machine.MSBulkInEp = (pphost->device_prop.Ep_Desc[0][1].bEndpointAddress);
|
MSC_Machine.MSBulkInEp = (pphost->device_prop.Ep_Desc[0][1].bEndpointAddress);
|
||||||
MSC_Machine.MSBulkInEpSize = pphost->device_prop.Ep_Desc[0][1].wMaxPacketSize;
|
MSC_Machine.MSBulkInEpSize = pphost->device_prop.Ep_Desc[0][1].wMaxPacketSize;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
MSC_Machine.MSBulkOutEp = (pphost->device_prop.Ep_Desc[0][1].bEndpointAddress);
|
MSC_Machine.MSBulkOutEp = (pphost->device_prop.Ep_Desc[0][1].bEndpointAddress);
|
||||||
MSC_Machine.MSBulkOutEpSize = pphost->device_prop.Ep_Desc[0][1].wMaxPacketSize;
|
MSC_Machine.MSBulkOutEpSize = pphost->device_prop.Ep_Desc[0][1].wMaxPacketSize;
|
||||||
}
|
}
|
||||||
@@ -101,7 +95,8 @@ static USBH_Status USBH_MSC_InterfaceInit(USB_OTG_CORE_HANDLE* pdev,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
pphost->usr_cb->USBH_USR_DeviceNotSupported();
|
pphost->usr_cb->USBH_USR_DeviceNotSupported();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,13 +107,15 @@ static USBH_Status USBH_MSC_InterfaceInit(USB_OTG_CORE_HANDLE* pdev,
|
|||||||
void USBH_MSC_InterfaceDeInit ( USB_OTG_CORE_HANDLE *pdev,
|
void USBH_MSC_InterfaceDeInit ( USB_OTG_CORE_HANDLE *pdev,
|
||||||
void *phost)
|
void *phost)
|
||||||
{
|
{
|
||||||
if (MSC_Machine.hc_num_out) {
|
if ( MSC_Machine.hc_num_out)
|
||||||
|
{
|
||||||
USB_OTG_HC_Halt(pdev, MSC_Machine.hc_num_out);
|
USB_OTG_HC_Halt(pdev, MSC_Machine.hc_num_out);
|
||||||
USBH_Free_Channel (pdev, MSC_Machine.hc_num_out);
|
USBH_Free_Channel (pdev, MSC_Machine.hc_num_out);
|
||||||
MSC_Machine.hc_num_out = 0;
|
MSC_Machine.hc_num_out = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MSC_Machine.hc_num_in) {
|
if ( MSC_Machine.hc_num_in)
|
||||||
|
{
|
||||||
USB_OTG_HC_Halt(pdev, MSC_Machine.hc_num_in);
|
USB_OTG_HC_Halt(pdev, MSC_Machine.hc_num_in);
|
||||||
USBH_Free_Channel (pdev, MSC_Machine.hc_num_in);
|
USBH_Free_Channel (pdev, MSC_Machine.hc_num_in);
|
||||||
MSC_Machine.hc_num_in = 0;
|
MSC_Machine.hc_num_in = 0;
|
||||||
@@ -140,14 +137,14 @@ static USBH_Status USBH_MSC_Handle(USB_OTG_CORE_HANDLE* pdev ,
|
|||||||
|
|
||||||
USBH_Status status = USBH_BUSY;
|
USBH_Status status = USBH_BUSY;
|
||||||
|
|
||||||
if (HCD_IsDeviceConnected(pdev)) {
|
if(HCD_IsDeviceConnected(pdev))
|
||||||
|
{
|
||||||
int appliStatus = pphost->usr_cb->USBH_USR_MSC_Application();
|
int appliStatus = pphost->usr_cb->USBH_USR_MSC_Application();
|
||||||
|
if(appliStatus != 0)
|
||||||
if (appliStatus != 0) {
|
{
|
||||||
status = USBH_APPLY_DEINIT;
|
status = USBH_APPLY_DEINIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -155,26 +152,22 @@ static USBH_Status USBH_MSC_Handle(USB_OTG_CORE_HANDLE* pdev ,
|
|||||||
|
|
||||||
volatile uint32_t cnt;
|
volatile uint32_t cnt;
|
||||||
volatile uint32_t cnt_int;
|
volatile uint32_t cnt_int;
|
||||||
void USBH_LL_systick()
|
void USBH_LL_systick() {
|
||||||
{
|
|
||||||
cnt++;
|
cnt++;
|
||||||
cnt_int++;
|
cnt_int++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void USBH_LL_setTimer()
|
void USBH_LL_setTimer() {
|
||||||
{
|
|
||||||
cnt=0;
|
cnt=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t USBH_LL_getTimer()
|
uint32_t USBH_LL_getTimer() {
|
||||||
{
|
|
||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int USBH_LL_open()
|
int USBH_LL_open() {
|
||||||
{
|
|
||||||
int timeoutDetect=100;
|
int timeoutDetect=100;
|
||||||
int timeoutStartup=3000;
|
int timeoutStartup=3000;
|
||||||
cnt_int=0; //reset timer
|
cnt_int=0; //reset timer
|
||||||
@@ -189,27 +182,21 @@ int USBH_LL_open()
|
|||||||
|
|
||||||
|
|
||||||
cnt_int=0;
|
cnt_int=0;
|
||||||
|
|
||||||
while(cnt_int<timeoutStartup) { //let pixy's led flashing pass
|
while(cnt_int<timeoutStartup) { //let pixy's led flashing pass
|
||||||
USBH_Process(&USB_OTG_Core, &USB_Host);
|
USBH_Process(&USB_OTG_Core, &USB_Host);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0; //ok
|
return 0; //ok
|
||||||
}
|
}
|
||||||
|
|
||||||
int USBH_LL_close()
|
int USBH_LL_close() {
|
||||||
{
|
|
||||||
USBH_Process(&USB_OTG_Core, &USB_Host);
|
USBH_Process(&USB_OTG_Core, &USB_Host);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int USBH_LL_send(const uint8_t* data, uint32_t len, uint16_t timeoutMs)
|
int USBH_LL_send(const uint8_t *data, uint32_t len, uint16_t timeoutMs) {
|
||||||
{
|
|
||||||
USB_OTG_CORE_HANDLE *pdev = &USB_OTG_Core;
|
USB_OTG_CORE_HANDLE *pdev = &USB_OTG_Core;
|
||||||
|
|
||||||
if (!HCD_IsDeviceConnected(pdev)) {
|
if(!HCD_IsDeviceConnected(pdev)) return -1;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
USBH_BulkSendData (pdev,
|
USBH_BulkSendData (pdev,
|
||||||
(uint8_t*)data,
|
(uint8_t*)data,
|
||||||
@@ -218,10 +205,7 @@ int USBH_LL_send(const uint8_t* data, uint32_t len, uint16_t timeoutMs)
|
|||||||
|
|
||||||
URB_STATE state;
|
URB_STATE state;
|
||||||
cnt_int=0; //reset timer
|
cnt_int=0; //reset timer
|
||||||
|
if(timeoutMs==0) timeoutMs=1000; //Force 1s timeout (testwise)
|
||||||
if (timeoutMs == 0) {
|
|
||||||
timeoutMs = 1000; //Force 1s timeout (testwise)
|
|
||||||
}
|
|
||||||
|
|
||||||
while((state=HCD_GetURB_State(pdev , MSC_Machine.hc_num_out)) == URB_IDLE &&
|
while((state=HCD_GetURB_State(pdev , MSC_Machine.hc_num_out)) == URB_IDLE &&
|
||||||
(timeoutMs==0 || cnt_int < timeoutMs));
|
(timeoutMs==0 || cnt_int < timeoutMs));
|
||||||
@@ -232,21 +216,16 @@ int USBH_LL_send(const uint8_t* data, uint32_t len, uint16_t timeoutMs)
|
|||||||
return -7; //timeout (error code like with libusb)
|
return -7; //timeout (error code like with libusb)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int USBH_LL_receive(uint8_t* data, uint32_t len, uint16_t timeoutMs)
|
int USBH_LL_receive(uint8_t *data, uint32_t len, uint16_t timeoutMs) {
|
||||||
{
|
|
||||||
|
|
||||||
USB_OTG_CORE_HANDLE *pdev = &USB_OTG_Core;
|
USB_OTG_CORE_HANDLE *pdev = &USB_OTG_Core;
|
||||||
|
|
||||||
if (!HCD_IsDeviceConnected(pdev)) {
|
if(!HCD_IsDeviceConnected(pdev)) return -1;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
USBH_BulkReceiveData (pdev,
|
USBH_BulkReceiveData (pdev,
|
||||||
data,
|
data,
|
||||||
@@ -255,10 +234,7 @@ int USBH_LL_receive(uint8_t* data, uint32_t len, uint16_t timeoutMs)
|
|||||||
|
|
||||||
URB_STATE state;
|
URB_STATE state;
|
||||||
cnt_int=0; //reset timer
|
cnt_int=0; //reset timer
|
||||||
|
if(timeoutMs==0) timeoutMs=1000; //Force 1s timeout (testwise)
|
||||||
if (timeoutMs == 0) {
|
|
||||||
timeoutMs = 1000; //Force 1s timeout (testwise)
|
|
||||||
}
|
|
||||||
|
|
||||||
while((state=HCD_GetURB_State(pdev , MSC_Machine.hc_num_in)) == URB_IDLE &&
|
while((state=HCD_GetURB_State(pdev , MSC_Machine.hc_num_in)) == URB_IDLE &&
|
||||||
(timeoutMs==0 || cnt_int < timeoutMs));
|
(timeoutMs==0 || cnt_int < timeoutMs));
|
||||||
@@ -268,9 +244,7 @@ int USBH_LL_receive(uint8_t* data, uint32_t len, uint16_t timeoutMs)
|
|||||||
STM_EVAL_LEDOn(LED3);
|
STM_EVAL_LEDOn(LED3);
|
||||||
return -7; //timeout (error code like with libusb)
|
return -7; //timeout (error code like with libusb)
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: discovery/src/usbh_msc_core.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-03 timolang@gmail.com 21dd1e2 Starting to integrate usb branch. Optimized Makefiles
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
/* Define to prevent recursive ----------------------------------------------*/
|
/* Define to prevent recursive ----------------------------------------------*/
|
||||||
#ifndef __USBH_MSC_CORE_H
|
#ifndef __USBH_MSC_CORE_H
|
||||||
@@ -36,3 +23,5 @@ uint32_t USBH_LL_getTimer();
|
|||||||
|
|
||||||
|
|
||||||
#endif /* __USBH_MSC_CORE_H */
|
#endif /* __USBH_MSC_CORE_H */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +1,10 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: discovery/src/usbh_usr.c
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-03 timolang@gmail.com 21dd1e2 Starting to integrate usb branch. Optimized Makefiles
|
|
||||||
* 2015-04-03 timolang@gmail.com 9a1d12a Refactored discovery, to use new project structure. Almost ready.
|
|
||||||
* 2015-04-25 timolang@gmail.com 416883c Pixy&Usb work with the new folder structure now.
|
|
||||||
* 2015-04-25 timolang@gmail.com 3d1e4b2 Simplified code a bit. Emulator does not work stable when replugging pixy.
|
|
||||||
* 2015-06-02 timolang@gmail.com 16bfdad Removed conflicting led usage from usb code.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "usbh_usr.h"
|
#include "usbh_usr.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
USBH_Usr_cb_TypeDef USR_Callbacks = {
|
USBH_Usr_cb_TypeDef USR_Callbacks =
|
||||||
|
{
|
||||||
USBH_USR_Init,
|
USBH_USR_Init,
|
||||||
USBH_USR_DeInit,
|
USBH_USR_DeInit,
|
||||||
USBH_USR_DeviceAttached,
|
USBH_USR_DeviceAttached,
|
||||||
@@ -209,7 +193,6 @@ USBH_USR_Status USBH_USR_UserInput(void)
|
|||||||
if(product_ok&&manufacturer_ok&&serial_ok) {
|
if(product_ok&&manufacturer_ok&&serial_ok) {
|
||||||
return USBH_USR_RESP_OK;
|
return USBH_USR_RESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
return USBH_USR_NO_RESP;
|
return USBH_USR_NO_RESP;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,3 +226,4 @@ void USBH_USR_DeInit(void)
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: discovery/src/usbh_usr.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-03 timolang@gmail.com 21dd1e2 Starting to integrate usb branch. Optimized Makefiles
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
#ifndef __USH_USR_H__
|
#ifndef __USH_USR_H__
|
||||||
@@ -58,3 +45,7 @@ void USBH_USR_UnrecoveredError(void);
|
|||||||
#endif /*__USH_USR_H__*/
|
#endif /*__USH_USR_H__*/
|
||||||
|
|
||||||
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -33,11 +33,11 @@
|
|||||||
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="1"/>
|
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="1"/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="build/discoverpixy.elf"/>
|
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="build/discoverpixy.elf"/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="discoverpixy discovery"/>
|
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="discoverpixy"/>
|
||||||
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/>
|
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/>
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="cdt.managedbuild.toolchain.gnu.cross.base.1368576398"/>
|
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="cdt.managedbuild.toolchain.gnu.cross.base.1368576398"/>
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||||
<listEntry value="/discoverpixy discovery"/>
|
<listEntry value="/discoverpixy"/>
|
||||||
</listAttribute>
|
</listAttribute>
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||||
<listEntry value="4"/>
|
<listEntry value="4"/>
|
||||||
1
doc/.gitignore
vendored
1
doc/.gitignore
vendored
@@ -1,3 +1,2 @@
|
|||||||
*.*~
|
*.*~
|
||||||
html/
|
html/
|
||||||
latex/
|
|
||||||
|
|||||||
BIN
doc/docu.odt
BIN
doc/docu.odt
Binary file not shown.
BIN
doc/docu.pdf
BIN
doc/docu.pdf
Binary file not shown.
BIN
doc/refman.pdf
BIN
doc/refman.pdf
Binary file not shown.
5
emulator/.gitignore
vendored
5
emulator/.gitignore
vendored
@@ -5,8 +5,9 @@ qt/*.o
|
|||||||
qt/*.a
|
qt/*.a
|
||||||
qt/ui_*
|
qt/ui_*
|
||||||
qt/moc_*
|
qt/moc_*
|
||||||
qt/Makefile
|
qt/Makefile*
|
||||||
|
qt/debug
|
||||||
|
qt/release
|
||||||
|
|
||||||
libs/*/obj
|
libs/*/obj
|
||||||
libs/*/*.a
|
libs/*/*.a
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ QT_DIR=./qt
|
|||||||
COMMON_DIR=../common
|
COMMON_DIR=../common
|
||||||
|
|
||||||
#Tools
|
#Tools
|
||||||
CC=gcc -fdiagnostics-color=auto
|
CC=gcc #-fdiagnostics=auto
|
||||||
GDB=gdb
|
GDB=gdb
|
||||||
|
|
||||||
|
|
||||||
@@ -24,17 +24,22 @@ INCLUDES:=$(addprefix -I,$(INCLUDES))
|
|||||||
QT_LIB=$(QT_DIR)/libemulatorqt.a
|
QT_LIB=$(QT_DIR)/libemulatorqt.a
|
||||||
|
|
||||||
|
|
||||||
CPPFLAGS= -march=x86-64 -mtune=generic -fPIC $(INCLUDES)
|
CPPFLAGS= -march=x86-64 -mtune=generic #-fPIC
|
||||||
CFLAGS= -O0 -g -std=c99
|
CPPFLAGS+= $(INCLUDES)
|
||||||
|
CFLAGS= -O0 -g -std=c99 -mwindows
|
||||||
|
|
||||||
|
|
||||||
LIBS= pixy usb-1.0 boost_system boost_timer boost_chrono
|
LIBS= emulatorqt pixy usb-1.0
|
||||||
LIBS+=Qt5Core Qt5Gui Qt5Widgets emulatorqt m stdc++
|
LIBS+= boost_system-mgw49-mt-1_58 boost_timer-mgw49-mt-1_58 boost_chrono-mgw49-mt-1_58
|
||||||
|
LIBS+= Qt5Core Qt5Gui Qt5Widgets m stdc++
|
||||||
|
|
||||||
|
LDFLAGS= -static-libgcc -static-libstdc++ #-Wl,-t -Wl,--Map=a.map
|
||||||
LDFLAGS= -L$(QT_DIR) $(addprefix -l,$(LIBS))
|
LDFLAGS+= -L$(QT_DIR)
|
||||||
LDFLAGS+= -L$(LIB_DIR)/Pixy
|
LDFLAGS+= -L$(LIB_DIR)/Pixy
|
||||||
|
LDFLAGS+= -L$(LIB_DIR)/boost/lib
|
||||||
|
LDFLAGS+= -LC:/Qt/5.4/mingw491_32/lib
|
||||||
|
LDFLAGS+= -L$(LIB_DIR)/Pixy/windows
|
||||||
|
LDFLAGS+= $(addprefix -l,$(LIBS))
|
||||||
|
|
||||||
#Finding Input files
|
#Finding Input files
|
||||||
CFILES=$(shell find . -maxdepth 1 -name '*.c')
|
CFILES=$(shell find . -maxdepth 1 -name '*.c')
|
||||||
@@ -58,7 +63,7 @@ debug: all
|
|||||||
$(GDB) ./build/emulator
|
$(GDB) ./build/emulator
|
||||||
|
|
||||||
$(QT_LIB):
|
$(QT_LIB):
|
||||||
cd $(QT_DIR) && qmake &&make
|
cd $(QT_DIR) && qmake && $(MAKE)
|
||||||
|
|
||||||
#objects to elf
|
#objects to elf
|
||||||
$(BUILD_DIR)/$(TARGET): $(OBJS) $(COMMON_OBJS) $(QT_LIB)
|
$(BUILD_DIR)/$(TARGET): $(OBJS) $(COMMON_OBJS) $(QT_LIB)
|
||||||
@@ -83,7 +88,7 @@ $(OBJ_DIR)/%.o: $(COMMON_DIR)/%.c
|
|||||||
|
|
||||||
#Clean Obj files and builded stuff
|
#Clean Obj files and builded stuff
|
||||||
clean:
|
clean:
|
||||||
cd $(QT_DIR) && $(MAKE) clean && $(RM) Makefile && $(RM) *.a
|
cd $(QT_DIR) && $(MAKE) clean && $(RM) Makefile* && $(RM) *.a && $(RMDIR) debug release
|
||||||
$(RMDIR) $(BUILD_DIR) $(OBJ_DIR)
|
$(RMDIR) $(BUILD_DIR) $(OBJ_DIR)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,11 +17,13 @@ OBJ_DIR=./obj
|
|||||||
#Architecture flags
|
#Architecture flags
|
||||||
|
|
||||||
#Compiler, Linker Options
|
#Compiler, Linker Options
|
||||||
CPPFLAGS=-I$(INC_DIR) -D__LINUX__=1 -DHOST=1 #-DDEBUG=1
|
CPPFLAGS=-I$(INC_DIR) -DHOST=1 #-D__LINUX__=1 -DDEBUG=1
|
||||||
CFLAGS=$(ARCH_FLAGS) -O0 -g #-ffunction-sections -fdata-sections -g
|
CFLAGS=$(ARCH_FLAGS) -O0 -g #-ffunction-sections -fdata-sections -g
|
||||||
#CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork
|
#CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork
|
||||||
#CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
#CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
||||||
CFLAGS+=-I/usr/include/libusb-1.0
|
CFLAGS+=-I/usr/include/libusb-1.0
|
||||||
|
CFLAGS+=-I../boost/include/
|
||||||
|
CFLAGS+=-I./windows/
|
||||||
|
|
||||||
#Finding Input files
|
#Finding Input files
|
||||||
CFILES=$(shell find $(SRC_DIR) -name '*.cpp')
|
CFILES=$(shell find $(SRC_DIR) -name '*.cpp')
|
||||||
|
|||||||
BIN
emulator/libs/Pixy/windows/libusb-1.0.dll
Normal file
BIN
emulator/libs/Pixy/windows/libusb-1.0.dll
Normal file
Binary file not shown.
BIN
emulator/libs/Pixy/windows/libusb-1.0.dll.a
Normal file
BIN
emulator/libs/Pixy/windows/libusb-1.0.dll.a
Normal file
Binary file not shown.
1970
emulator/libs/Pixy/windows/libusb.h
Normal file
1970
emulator/libs/Pixy/windows/libusb.h
Normal file
File diff suppressed because it is too large
Load Diff
2
emulator/libs/boost/.gitignore
vendored
Normal file
2
emulator/libs/boost/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
include
|
||||||
|
lib
|
||||||
BIN
emulator/libs/boost/boost.rar
Normal file
BIN
emulator/libs/boost/boost.rar
Normal file
Binary file not shown.
2
emulator/libs/boost/readme.txt
Normal file
2
emulator/libs/boost/readme.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
This directory is only needed on windows, and if you do not have boost installed.
|
||||||
|
Extract the rar file here, to get boost 1.58 header files and the libraries that we need for discoverpixy
|
||||||
@@ -8,7 +8,7 @@ QT += widgets gui
|
|||||||
|
|
||||||
TARGET = emulatorqt
|
TARGET = emulatorqt
|
||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
CONFIG += staticlib
|
CONFIG += staticlib debug
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
mainwindow.cpp \
|
mainwindow.cpp \
|
||||||
@@ -30,3 +30,6 @@ INCLUDEPATH+= ../../common/lowlevel/ \
|
|||||||
FORMS += \
|
FORMS += \
|
||||||
mainwindow.ui
|
mainwindow.ui
|
||||||
|
|
||||||
|
DESTDIR = $$_PRO_FILE_PWD_ #force windows to not create subfolders
|
||||||
|
|
||||||
|
#QMAKE_CXXFLAGS+= -v
|
||||||
|
|||||||
@@ -1,17 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: emulator/qt/ll_filesystem.cpp
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-05-10 timolang@gmail.com e2bce8f Added filesystem module, tests and implementation for it in emulator.
|
|
||||||
* 2015-06-07 timolang@gmail.com 4b5768c Improved Comments in whole emulator. Finalized emulator section in docu.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "ll_filesystem.h"
|
#include "ll_filesystem.h"
|
||||||
}
|
}
|
||||||
@@ -23,21 +9,17 @@ extern "C" {
|
|||||||
|
|
||||||
QDir rootdir ("./emulated"); //Create a QDir which points to the "root" of the emulated filesystem
|
QDir rootdir ("./emulated"); //Create a QDir which points to the "root" of the emulated filesystem
|
||||||
|
|
||||||
bool ll_filesystem_init()
|
bool ll_filesystem_init() {
|
||||||
{
|
|
||||||
if(!rootdir.exists()) { //if our root dir is nonexistent
|
if(!rootdir.exists()) { //if our root dir is nonexistent
|
||||||
qWarning() << "Filesystem can not be emulated because the 'emulated' folder does not exist";
|
qWarning() << "Filesystem can not be emulated because the 'emulated' folder does not exist";
|
||||||
return false; //mark an error
|
return false; //mark an error
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DIRECTORY_STRUCT* ll_filesystem_dir_open(const char* path)
|
DIRECTORY_STRUCT* ll_filesystem_dir_open(const char* path) {
|
||||||
{
|
|
||||||
QDir d(rootdir); //Make a copy of the rootdir QDir instance
|
QDir d(rootdir); //Make a copy of the rootdir QDir instance
|
||||||
d.cd(path); //Change the directory to the passed path
|
d.cd(path); //Change the directory to the passed path
|
||||||
|
|
||||||
if(!d.exists()) {
|
if(!d.exists()) {
|
||||||
return NULL; //mark an error
|
return NULL; //mark an error
|
||||||
}
|
}
|
||||||
@@ -56,18 +38,15 @@ DIRECTORY_STRUCT* ll_filesystem_dir_open(const char* path)
|
|||||||
entry->fattrib = 0;
|
entry->fattrib = 0;
|
||||||
entry->fname = new char[fi.fileName().length()+1]; //reserve memory for filename
|
entry->fname = new char[fi.fileName().length()+1]; //reserve memory for filename
|
||||||
strcpy(entry->fname,fi.fileName().toStdString().c_str()); //copy filename into struct
|
strcpy(entry->fname,fi.fileName().toStdString().c_str()); //copy filename into struct
|
||||||
|
|
||||||
if(fi.isDir()) { //it's a direcory
|
if(fi.isDir()) { //it's a direcory
|
||||||
entry->fattrib|=F_DIR; //set directory attribute
|
entry->fattrib|=F_DIR; //set directory attribute
|
||||||
entry->fsize = 0;
|
entry->fsize = 0;
|
||||||
} else { //it's a file
|
} else { //it's a file
|
||||||
entry->fsize = fi.size(); //set filesize
|
entry->fsize = fi.size(); //set filesize
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fi.isHidden()) { //the file is hidden
|
if(fi.isHidden()) { //the file is hidden
|
||||||
entry->fattrib|=F_HID;
|
entry->fattrib|=F_HID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!fi.isWritable()) { //the file is not writable
|
if(!fi.isWritable()) { //the file is not writable
|
||||||
entry->fattrib|=F_RDO; //set readonly attribue
|
entry->fattrib|=F_RDO; //set readonly attribue
|
||||||
}
|
}
|
||||||
@@ -86,13 +65,11 @@ DIRECTORY_STRUCT* ll_filesystem_dir_open(const char* path)
|
|||||||
return directory; //return filled directory struct
|
return directory; //return filled directory struct
|
||||||
}
|
}
|
||||||
|
|
||||||
void ll_filesystem_dir_close(DIRECTORY_STRUCT* dir)
|
void ll_filesystem_dir_close(DIRECTORY_STRUCT* dir) {
|
||||||
{
|
|
||||||
if(dir!=NULL) { //passed handle is valid
|
if(dir!=NULL) { //passed handle is valid
|
||||||
for(int i=0; i<dir->num_files; i++) { //foreach file
|
for(int i=0; i<dir->num_files; i++) { //foreach file
|
||||||
delete dir->files[i].fname; //delete filename buffer
|
delete dir->files[i].fname; //delete filename buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] dir->files; //delete file array
|
delete[] dir->files; //delete file array
|
||||||
delete dir; //delete structure itself
|
delete dir; //delete structure itself
|
||||||
}
|
}
|
||||||
@@ -104,15 +81,12 @@ struct QT_FILE_HANDLE : FILE_HANDLE { //..derived from the FILE_HANDLE (of the F
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
FILE_HANDLE* ll_filesystem_file_open(const char* filename)
|
FILE_HANDLE* ll_filesystem_file_open(const char* filename) {
|
||||||
{
|
|
||||||
if(!rootdir.exists()) {
|
if(!rootdir.exists()) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString filepath = rootdir.absoluteFilePath(filename); //get the absolute path to the requested file
|
QString filepath = rootdir.absoluteFilePath(filename); //get the absolute path to the requested file
|
||||||
QFile* f = new QFile(filepath); //create a QFile instance to the requested file
|
QFile* f = new QFile(filepath); //create a QFile instance to the requested file
|
||||||
|
|
||||||
if(!f->exists()) { //File does not exist
|
if(!f->exists()) { //File does not exist
|
||||||
return NULL; //mark error
|
return NULL; //mark error
|
||||||
}
|
}
|
||||||
@@ -131,32 +105,25 @@ FILE_HANDLE* ll_filesystem_file_open(const char* filename)
|
|||||||
return fh;
|
return fh;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ll_filesystem_file_close(FILE_HANDLE* handle)
|
void ll_filesystem_file_close(FILE_HANDLE* handle) {
|
||||||
{
|
|
||||||
if(handle!=NULL) { //passed handle is valid
|
if(handle!=NULL) { //passed handle is valid
|
||||||
QT_FILE_HANDLE* fh = static_cast<QT_FILE_HANDLE*>(handle); //cast pointer to QT_FILE_HANDLE
|
QT_FILE_HANDLE* fh = static_cast<QT_FILE_HANDLE*>(handle); //cast pointer to QT_FILE_HANDLE
|
||||||
|
|
||||||
if(fh->file->isOpen()) { //if the file is still open
|
if(fh->file->isOpen()) { //if the file is still open
|
||||||
fh->file->close(); //close the file
|
fh->file->close(); //close the file
|
||||||
}
|
}
|
||||||
|
|
||||||
delete fh->file; //delete QFile instance
|
delete fh->file; //delete QFile instance
|
||||||
delete fh; //delete the fle
|
delete fh; //delete the fle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE_STATUS ll_filesystem_file_seek(FILE_HANDLE* handle, uint32_t offset)
|
FILE_STATUS ll_filesystem_file_seek(FILE_HANDLE* handle, uint32_t offset) {
|
||||||
{
|
|
||||||
if(handle==NULL) {
|
if(handle==NULL) {
|
||||||
return F_INVALIDPARAM;
|
return F_INVALIDPARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_FILE_HANDLE* fh = static_cast<QT_FILE_HANDLE*>(handle); //cast pointer to QT_FILE_HANDLE
|
QT_FILE_HANDLE* fh = static_cast<QT_FILE_HANDLE*>(handle); //cast pointer to QT_FILE_HANDLE
|
||||||
|
|
||||||
if(!fh->file->isOpen()) { //file is not open
|
if(!fh->file->isOpen()) { //file is not open
|
||||||
return F_DISKERROR;
|
return F_DISKERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(offset>=fh->file->size()) { //offset exeeds filesize
|
if(offset>=fh->file->size()) { //offset exeeds filesize
|
||||||
return F_INVALIDPARAM;
|
return F_INVALIDPARAM;
|
||||||
}
|
}
|
||||||
@@ -169,30 +136,22 @@ FILE_STATUS ll_filesystem_file_seek(FILE_HANDLE* handle, uint32_t offset)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE_STATUS ll_filesystem_file_read(FILE_HANDLE* handle, uint8_t* buf, uint32_t size)
|
FILE_STATUS ll_filesystem_file_read(FILE_HANDLE* handle, uint8_t* buf, uint32_t size) {
|
||||||
{
|
|
||||||
if(handle==NULL || buf==NULL) {
|
if(handle==NULL || buf==NULL) {
|
||||||
return F_INVALIDPARAM;
|
return F_INVALIDPARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_FILE_HANDLE* fh = static_cast<QT_FILE_HANDLE*>(handle); //cast pointer to QT_FILE_HANDLE
|
QT_FILE_HANDLE* fh = static_cast<QT_FILE_HANDLE*>(handle); //cast pointer to QT_FILE_HANDLE
|
||||||
|
|
||||||
if(!fh->file->isOpen()) { //file is not open
|
if(!fh->file->isOpen()) { //file is not open
|
||||||
return F_DISKERROR;
|
return F_DISKERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!fh->file->isReadable()) { //file is not readable
|
if(!fh->file->isReadable()) { //file is not readable
|
||||||
return F_EACCESS;
|
return F_EACCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 bytesRead = fh->file->read((char*)buf,size); //try to read desired amount of bytes
|
qint64 bytesRead = fh->file->read((char*)buf,size); //try to read desired amount of bytes
|
||||||
|
|
||||||
if(bytesRead<0) { //read failed
|
if(bytesRead<0) { //read failed
|
||||||
return F_DISKERROR;
|
return F_DISKERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
fh->fpos+=bytesRead; //increase file position (for user)
|
fh->fpos+=bytesRead; //increase file position (for user)
|
||||||
|
|
||||||
if(bytesRead!=size) { //we got less bytes than expected
|
if(bytesRead!=size) { //we got less bytes than expected
|
||||||
return F_EOF; //we reached the end of the file
|
return F_EOF; //we reached the end of the file
|
||||||
} else {
|
} else {
|
||||||
@@ -200,33 +159,26 @@ FILE_STATUS ll_filesystem_file_read(FILE_HANDLE* handle, uint8_t* buf, uint32_t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE_STATUS ll_filesystem_file_write(FILE_HANDLE* handle, uint8_t* buf, uint32_t size)
|
FILE_STATUS ll_filesystem_file_write(FILE_HANDLE* handle, uint8_t* buf, uint32_t size) {
|
||||||
{
|
|
||||||
if(handle==NULL) {
|
if(handle==NULL) {
|
||||||
return F_INVALIDPARAM;
|
return F_INVALIDPARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_FILE_HANDLE* fh = static_cast<QT_FILE_HANDLE*>(handle); //cast pointer to QT_FILE_HANDLE
|
QT_FILE_HANDLE* fh = static_cast<QT_FILE_HANDLE*>(handle); //cast pointer to QT_FILE_HANDLE
|
||||||
|
|
||||||
if(!fh->file->isOpen()) { //file is not open
|
if(!fh->file->isOpen()) { //file is not open
|
||||||
return F_DISKERROR;
|
return F_DISKERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!fh->file->isWritable()) { //file is not writable
|
if(!fh->file->isWritable()) { //file is not writable
|
||||||
return F_EACCESS;
|
return F_EACCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 bytesWritten = fh->file->write((char*)buf,size); //try to write desired amount of bytes
|
qint64 bytesWritten = fh->file->write((char*)buf,size); //try to write desired amount of bytes
|
||||||
|
|
||||||
if(bytesWritten<0) { //write failed
|
if(bytesWritten<0) { //write failed
|
||||||
return F_DISKERROR;
|
return F_DISKERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
fh->fpos+=bytesWritten; //increase file position (for user)
|
fh->fpos+=bytesWritten; //increase file position (for user)
|
||||||
|
|
||||||
if(bytesWritten!=size) { //we wrote less bytes than expected
|
if(bytesWritten!=size) { //we wrote less bytes than expected
|
||||||
return F_EOF; //we reached the end of the file
|
return F_EOF; //we reached the end of the file
|
||||||
} else {
|
} else {
|
||||||
return F_OK;
|
return F_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: emulator/qt/ll_system.cpp
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-03 timolang@gmail.com 1f2af9f Added more tft functions to common and emulator. Fixed eventloop.
|
|
||||||
* 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
|
|
||||||
* 2015-04-25 timolang@gmail.com 3d1e4b2 Simplified code a bit. Emulator does not work stable when replugging pixy.
|
|
||||||
* 2015-04-25 timolang@gmail.com 0858b0d Fixed some bugs when receiving large data.
|
|
||||||
* 2015-05-09 timolang@gmail.com c652b6b Improved Emulator Gui
|
|
||||||
* 2015-06-07 timolang@gmail.com 4b5768c Improved Comments in whole emulator. Finalized emulator section in docu.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
@@ -23,23 +5,19 @@ extern "C" {
|
|||||||
#include "ll_system.h"
|
#include "ll_system.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ll_system_init()
|
bool ll_system_init() {
|
||||||
{
|
|
||||||
return true; //nothing to initialize here, apart from the stuff which is done in the main method.
|
return true; //nothing to initialize here, apart from the stuff which is done in the main method.
|
||||||
}
|
}
|
||||||
|
|
||||||
void ll_system_delay(uint32_t msec)
|
void ll_system_delay(uint32_t msec) {
|
||||||
{
|
|
||||||
QThread::msleep(msec); //Let the app_process() Thread sleep
|
QThread::msleep(msec); //Let the app_process() Thread sleep
|
||||||
}
|
}
|
||||||
|
|
||||||
void ll_system_process()
|
void ll_system_process() {
|
||||||
{
|
|
||||||
QApplication::processEvents(); //Process pending qt events
|
QApplication::processEvents(); //Process pending qt events
|
||||||
QThread::msleep(1); //Sleep for 1ms, to keep the cpu load down
|
QThread::msleep(1); //Sleep for 1ms, to keep the cpu load down
|
||||||
}
|
}
|
||||||
|
|
||||||
void ll_system_toggle_led()
|
void ll_system_toggle_led() {
|
||||||
{
|
|
||||||
//No led emulated :(
|
//No led emulated :(
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: emulator/qt/ll_tft.cpp
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-03 timolang@gmail.com 51089aa Refactored Project Structure for use with emulator
|
|
||||||
* 2015-04-03 timolang@gmail.com 1f2af9f Added more tft functions to common and emulator. Fixed eventloop.
|
|
||||||
* 2015-04-03 timolang@gmail.com 1aa9194 Fixed Drawing of rects in Emulator. Got frames from pixy to emulator. Slooooow.
|
|
||||||
* 2015-04-27 aaron@duckpond.ch aed90ef Drawcircle added (emulator)
|
|
||||||
* 2015-04-27 timolang@gmail.com e249fb2 Added font support
|
|
||||||
* 2015-05-15 timolang@gmail.com b08a897 Added tft method to draw a bmp from filesystem. Added another font to emulator.
|
|
||||||
* 2015-06-07 timolang@gmail.com 4b5768c Improved Comments in whole emulator. Finalized emulator section in docu.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -25,8 +6,7 @@ extern "C" {
|
|||||||
|
|
||||||
MainWindow* mainwindow;
|
MainWindow* mainwindow;
|
||||||
|
|
||||||
bool ll_tft_init()
|
bool ll_tft_init() {
|
||||||
{
|
|
||||||
mainwindow = new MainWindow(); //create the designed window
|
mainwindow = new MainWindow(); //create the designed window
|
||||||
mainwindow->show(); //open it (non blocking)
|
mainwindow->show(); //open it (non blocking)
|
||||||
return true;
|
return true;
|
||||||
@@ -35,94 +15,69 @@ bool ll_tft_init()
|
|||||||
|
|
||||||
//the following functions redirect the call to the mainwindow, to a function with the same signature
|
//the following functions redirect the call to the mainwindow, to a function with the same signature
|
||||||
|
|
||||||
void ll_tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
|
void ll_tft_draw_line(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color) {
|
||||||
{
|
|
||||||
mainwindow->draw_line(x1,y1,x2,y2,color);
|
mainwindow->draw_line(x1,y1,x2,y2,color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ll_tft_clear(uint16_t color)
|
void ll_tft_clear(uint16_t color) {
|
||||||
{
|
|
||||||
mainwindow->clear(color);
|
mainwindow->clear(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ll_tft_draw_pixel(uint16_t x, uint16_t y, uint16_t color)
|
void ll_tft_draw_pixel(uint16_t x,uint16_t y,uint16_t color) {
|
||||||
{
|
|
||||||
mainwindow->draw_pixel(x,y,color);
|
mainwindow->draw_pixel(x,y,color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ll_tft_draw_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
|
void ll_tft_draw_rectangle(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2, uint16_t color) {
|
||||||
{
|
|
||||||
mainwindow->draw_rectangle(x1,y1,x2,y2,color);
|
mainwindow->draw_rectangle(x1,y1,x2,y2,color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ll_tft_fill_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
|
void ll_tft_fill_rectangle(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2, uint16_t color) {
|
||||||
{
|
|
||||||
mainwindow->fill_rectangle(x1,y1,x2,y2,color);
|
mainwindow->fill_rectangle(x1,y1,x2,y2,color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ll_tft_draw_bitmap_unscaled(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint16_t* dat)
|
void ll_tft_draw_bitmap_unscaled(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint16_t* dat) {
|
||||||
{
|
|
||||||
mainwindow->draw_bitmap_unscaled(x,y,width,height,dat);
|
mainwindow->draw_bitmap_unscaled(x,y,width,height,dat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ll_tft_draw_circle(uint16_t x, uint16_t y, uint16_t r, uint16_t color)
|
void ll_tft_draw_circle(uint16_t x, uint16_t y, uint16_t r, uint16_t color) {
|
||||||
{
|
|
||||||
mainwindow->draw_circle(x,y,r,color);
|
mainwindow->draw_circle(x,y,r,color);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t ll_tft_num_fonts()
|
uint8_t ll_tft_num_fonts() {
|
||||||
{
|
|
||||||
return 2; //we have two fonts (see below)
|
return 2; //we have two fonts (see below)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Helper function to get the QFont to the corresponding font number
|
//Helper function to get the QFont to the corresponding font number
|
||||||
//Note: only return monospaced fonts!!!
|
//Note: only return monospaced fonts!!!
|
||||||
QFont get_font(uint8_t fontnum)
|
QFont get_font(uint8_t fontnum) {
|
||||||
{
|
|
||||||
switch(fontnum) {
|
switch(fontnum) {
|
||||||
case 0:
|
case 0:
|
||||||
return QFont("Monospace", 8);
|
return QFont("Courier New",8);
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
return QFont("DejaVu Sans Mono", 14);
|
return QFont("Courier New",14);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return QFont();
|
return QFont();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint8_t ll_tft_font_height(uint8_t fontnum)
|
uint8_t ll_tft_font_height(uint8_t fontnum) {
|
||||||
{
|
|
||||||
QFont f = get_font(fontnum);
|
QFont f = get_font(fontnum);
|
||||||
|
if(f == QFont()) return -1;
|
||||||
if (f == QFont()) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
QFontMetrics m(f); //use font metcris object to calculate height of font
|
QFontMetrics m(f); //use font metcris object to calculate height of font
|
||||||
return m.height();
|
return m.height();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t ll_tft_font_width(uint8_t fontnum)
|
uint8_t ll_tft_font_width(uint8_t fontnum) {
|
||||||
{
|
|
||||||
QFont f = get_font(fontnum);
|
QFont f = get_font(fontnum);
|
||||||
|
if(f == QFont()) return -1;
|
||||||
if (f == QFont()) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
QFontMetrics m(f); //use font metcris object to calculate width of font
|
QFontMetrics m(f); //use font metcris object to calculate width of font
|
||||||
return m.averageCharWidth();
|
return m.averageCharWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ll_tft_draw_char(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, char c)
|
void ll_tft_draw_char(uint16_t x, uint16_t y, uint16_t color, uint16_t bgcolor, uint8_t font, char c) {
|
||||||
{
|
|
||||||
QFont f = get_font(font);
|
QFont f = get_font(font);
|
||||||
|
if(f == QFont()) return; //if the font is the default-font, we want to abort.
|
||||||
if (f == QFont()) {
|
|
||||||
return; //if the font is the default-font, we want to abort.
|
|
||||||
}
|
|
||||||
|
|
||||||
mainwindow->draw_char(x,y,color,bgcolor,f,c);
|
mainwindow->draw_char(x,y,color,bgcolor,f,c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,25 +1,10 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: emulator/qt/ll_touch.cpp
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-27 timolang@gmail.com 259d446 Added touch support to emulator. Implemented basic touch function.
|
|
||||||
* 2015-06-01 timolang@gmail.com eb573bc Finalized calibration. Fixed a bug in screen module.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "ll_touch.h"
|
#include "ll_touch.h"
|
||||||
#include "touch.h"
|
#include "touch.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ll_touch_init()
|
bool ll_touch_init() {
|
||||||
{
|
|
||||||
touch_set_value_convert_mode(false); //tell the touch module that we don't need calibration or value conversion
|
touch_set_value_convert_mode(false); //tell the touch module that we don't need calibration or value conversion
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: emulator/qt/main.cpp
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-03 timolang@gmail.com 51089aa Refactored Project Structure for use with emulator
|
|
||||||
* 2015-04-03 timolang@gmail.com 1f2af9f Added more tft functions to common and emulator. Fixed eventloop.
|
|
||||||
* 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
|
|
||||||
* 2015-04-07 timolang@gmail.com 383fc86 Simplified Emulator (main)
|
|
||||||
* 2015-04-25 timolang@gmail.com 3d1e4b2 Simplified code a bit. Emulator does not work stable when replugging pixy.
|
|
||||||
* 2015-06-07 timolang@gmail.com 4b5768c Improved Comments in whole emulator. Finalized emulator section in docu.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QtConcurrent/QtConcurrent>
|
#include <QtConcurrent/QtConcurrent>
|
||||||
|
|
||||||
@@ -25,18 +7,19 @@ extern "C" {
|
|||||||
void app_process(); //Processes one eventloop of the app
|
void app_process(); //Processes one eventloop of the app
|
||||||
}
|
}
|
||||||
|
|
||||||
void app_loop()
|
void app_loop() {
|
||||||
{
|
|
||||||
while(!QApplication::closingDown()) { //as long as the application is not terminating
|
while(!QApplication::closingDown()) { //as long as the application is not terminating
|
||||||
app_process(); //let the application process it's events
|
app_process(); //let the application process it's events
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[]) {
|
||||||
{
|
|
||||||
QApplication app(argc,argv); //Process qt-specific commandline arguments and create event loop
|
QApplication app(argc,argv); //Process qt-specific commandline arguments and create event loop
|
||||||
app_init(); //Let the application initialize it self
|
app_init(); //Let the application initialize it self
|
||||||
|
|
||||||
QtConcurrent::run(&app_loop); //Start a thread that executes app_loop
|
QtConcurrent::run(&app_loop); //Start a thread that executes app_loop
|
||||||
return app.exec(); //Run the event loop until the last window is closed.
|
return app.exec(); //Run the event loop until the last window is closed.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,29 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: emulator/qt/mainwindow.cpp
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-03 timolang@gmail.com 51089aa Refactored Project Structure for use with emulator
|
|
||||||
* 2015-04-03 timolang@gmail.com 1f2af9f Added more tft functions to common and emulator. Fixed eventloop.
|
|
||||||
* 2015-04-03 timolang@gmail.com c570bda Fixed bug in color conversion
|
|
||||||
* 2015-04-03 timolang@gmail.com 867f766 Some gui changes.
|
|
||||||
* 2015-04-03 timolang@gmail.com 1aa9194 Fixed Drawing of rects in Emulator. Got frames from pixy to emulator. Slooooow.
|
|
||||||
* 2015-04-04 timolang@gmail.com 0636381 Improved tff_draw_bitmap_unscaled in emulator.
|
|
||||||
* 2015-04-27 timolang@gmail.com 259d446 Added touch support to emulator. Implemented basic touch function.
|
|
||||||
* 2015-04-27 aaron@duckpond.ch aed90ef Drawcircle added (emulator)
|
|
||||||
* 2015-04-27 timolang@gmail.com e249fb2 Added font support
|
|
||||||
* 2015-05-09 timolang@gmail.com c652b6b Improved Emulator Gui
|
|
||||||
* 2015-05-25 timolang@gmail.com 911760e Added "Mouse Position"-Label to Emulator.
|
|
||||||
* 2015-06-01 timolang@gmail.com 06227da Added calibrate screen (WIP). fixed bug in emulator drawing.
|
|
||||||
* 2015-06-07 timolang@gmail.com 4b5768c Improved Comments in whole emulator. Finalized emulator section in docu.
|
|
||||||
* 2015-06-07 timolang@gmail.com 8752356 Started with tests in docu. fixed a small bug in emulator when drawing a rectangle.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@@ -40,8 +14,7 @@ extern "C" {
|
|||||||
#define DISPLAY_HEIGHT 240
|
#define DISPLAY_HEIGHT 240
|
||||||
|
|
||||||
//function to calculate QColor out of a RGB565 16bit color
|
//function to calculate QColor out of a RGB565 16bit color
|
||||||
QColor QColorFromRGB565(uint16_t color)
|
QColor QColorFromRGB565(uint16_t color) {
|
||||||
{
|
|
||||||
//interpolate colors
|
//interpolate colors
|
||||||
int R8 = (int) floor( (color>>(5+6)) * 255.0 / 31.0 + 0.5);
|
int R8 = (int) floor( (color>>(5+6)) * 255.0 / 31.0 + 0.5);
|
||||||
int G8 = (int) floor( ((color>>5)&0x3F) * 255.0 / 63.0 + 0.5);
|
int G8 = (int) floor( ((color>>5)&0x3F) * 255.0 / 63.0 + 0.5);
|
||||||
@@ -50,8 +23,7 @@ QColor QColorFromRGB565(uint16_t color)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//function to calculate QRgb out of a RGB565 16bit color
|
//function to calculate QRgb out of a RGB565 16bit color
|
||||||
QRgb QRgbFromRGB565(uint16_t color)
|
QRgb QRgbFromRGB565(uint16_t color) {
|
||||||
{
|
|
||||||
//interpolate colors
|
//interpolate colors
|
||||||
int R8 = (int) floor( (color>>(5+6)) * 255.0 / 31.0 + 0.5);
|
int R8 = (int) floor( (color>>(5+6)) * 255.0 / 31.0 + 0.5);
|
||||||
int G8 = (int) floor( ((color>>5)&0x3F) * 255.0 / 63.0 + 0.5);
|
int G8 = (int) floor( ((color>>5)&0x3F) * 255.0 / 63.0 + 0.5);
|
||||||
@@ -60,8 +32,7 @@ QRgb QRgbFromRGB565(uint16_t color)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), image(DISPLAY_WIDTH, DISPLAY_HEIGHT, QImage::Format_RGB16), ui(new Ui::MainWindow)
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), image(DISPLAY_WIDTH,DISPLAY_HEIGHT, QImage::Format_RGB16), ui(new Ui::MainWindow){
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
image.fill(Qt::black); //clear display buffer
|
image.fill(Qt::black); //clear display buffer
|
||||||
currentScale = 1; //start with scale factor 1
|
currentScale = 1; //start with scale factor 1
|
||||||
@@ -111,7 +82,6 @@ void MainWindow::draw_bitmap_unscaled(uint16_t x, uint16_t y, uint16_t width, ui
|
|||||||
|
|
||||||
for(int yi=0; yi<height; yi++) { //for each line
|
for(int yi=0; yi<height; yi++) { //for each line
|
||||||
uint32_t* line = (uint32_t*)img.scanLine(yi); //get the pointer to the imagedata of the current line
|
uint32_t* line = (uint32_t*)img.scanLine(yi); //get the pointer to the imagedata of the current line
|
||||||
|
|
||||||
for(int xi=0; xi<width; xi++) { //for each column
|
for(int xi=0; xi<width; xi++) { //for each column
|
||||||
*line++=QRgbFromRGB565(dat[yi*width+xi]); //set pixel
|
*line++=QRgbFromRGB565(dat[yi*width+xi]); //set pixel
|
||||||
}
|
}
|
||||||
@@ -182,22 +152,19 @@ bool MainWindow::eventFilter(QObject* obj, QEvent* evt)
|
|||||||
{
|
{
|
||||||
if(obj==ui->widgetDisplay) { //we received a redirect event from the target rectangle
|
if(obj==ui->widgetDisplay) { //we received a redirect event from the target rectangle
|
||||||
switch(evt->type()) {
|
switch(evt->type()) {
|
||||||
case QEvent::MouseMove: { //it's a mouse move event
|
case QEvent::MouseMove: //it's a mouse move event
|
||||||
|
{
|
||||||
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(evt); //get mouse event
|
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(evt); //get mouse event
|
||||||
QPoint p = (mouseEvent->pos()-QPoint(1,1))/currentScale; //calculate correct corrdinates (undo scale)
|
QPoint p = (mouseEvent->pos()-QPoint(1,1))/currentScale; //calculate correct corrdinates (undo scale)
|
||||||
|
|
||||||
if(p.x()<DISPLAY_WIDTH && p.y()<DISPLAY_HEIGHT) { //mouse position not out of bounds
|
if(p.x()<DISPLAY_WIDTH && p.y()<DISPLAY_HEIGHT) { //mouse position not out of bounds
|
||||||
//set mouse position text
|
//set mouse position text
|
||||||
ui->txtMousePos->setText(QString("Mouse Position: (%1,%2)").arg(p.x()).arg(p.y()));
|
ui->txtMousePos->setText(QString("Mouse Position: (%1,%2)").arg(p.x()).arg(p.y()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
default: break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,10 +178,7 @@ void MainWindow::checkAndSendEvent(QPoint pos, bool down)
|
|||||||
{
|
{
|
||||||
QPoint p = pos - ui->widgetDisplay->geometry().topLeft(); //make coordinate relative to target area (0,0)
|
QPoint p = pos - ui->widgetDisplay->geometry().topLeft(); //make coordinate relative to target area (0,0)
|
||||||
p/=currentScale; //undo scaling
|
p/=currentScale; //undo scaling
|
||||||
|
if(p.x()<0 || p.y()<0 || p.x() >= DISPLAY_WIDTH || p.y() >= DISPLAY_HEIGHT) return; //abort if out of bounds
|
||||||
if (p.x() < 0 || p.y() < 0 || p.x() >= DISPLAY_WIDTH || p.y() >= DISPLAY_HEIGHT) {
|
|
||||||
return; //abort if out of bounds
|
|
||||||
}
|
|
||||||
|
|
||||||
touch_add_raw_event(p.x(),p.y(),down?TOUCH_DOWN:TOUCH_UP); //submit touch event to touch module (common)
|
touch_add_raw_event(p.x(),p.y(),down?TOUCH_DOWN:TOUCH_UP); //submit touch event to touch module (common)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,3 @@
|
|||||||
/**************************************************************************************************************************************
|
|
||||||
* Project: discoverpixy
|
|
||||||
* Website: https://github.com/t-moe/discoverpixy
|
|
||||||
* Authors: Aaron Schmocker, Timo Lang
|
|
||||||
* Institution: BFH Bern University of Applied Sciences
|
|
||||||
* File: emulator/qt/mainwindow.h
|
|
||||||
*
|
|
||||||
* Version History:
|
|
||||||
* Date Autor Email SHA Changes
|
|
||||||
* 2015-04-03 timolang@gmail.com 51089aa Refactored Project Structure for use with emulator
|
|
||||||
* 2015-04-03 timolang@gmail.com 1f2af9f Added more tft functions to common and emulator. Fixed eventloop.
|
|
||||||
* 2015-04-03 timolang@gmail.com 1aa9194 Fixed Drawing of rects in Emulator. Got frames from pixy to emulator. Slooooow.
|
|
||||||
* 2015-04-27 timolang@gmail.com 259d446 Added touch support to emulator. Implemented basic touch function.
|
|
||||||
* 2015-04-27 aaron@duckpond.ch aed90ef Drawcircle added (emulator)
|
|
||||||
* 2015-04-27 timolang@gmail.com e249fb2 Added font support
|
|
||||||
* 2015-05-09 timolang@gmail.com c652b6b Improved Emulator Gui
|
|
||||||
* 2015-05-25 timolang@gmail.com 911760e Added "Mouse Position"-Label to Emulator.
|
|
||||||
* 2015-06-07 timolang@gmail.com 4b5768c Improved Comments in whole emulator. Finalized emulator section in docu.
|
|
||||||
*
|
|
||||||
**************************************************************************************************************************************/
|
|
||||||
|
|
||||||
#ifndef MAINWINDOW_H
|
#ifndef MAINWINDOW_H
|
||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
@@ -26,8 +5,7 @@
|
|||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui {
|
||||||
{
|
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
26
emulator/readme_windows.txt
Normal file
26
emulator/readme_windows.txt
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
Prerequisites:
|
||||||
|
- Qt5 for Windows (provides C:\Qt\5.4\mingw491_32 and C:\Qt\Tools\mingw491_32)
|
||||||
|
- Mingw msys-base (provides C:\MinGW\msys\1.0 and make, find )
|
||||||
|
- Boost (check emulator\libs\boost)
|
||||||
|
|
||||||
|
Steps:
|
||||||
|
- Open up the msys shell using the batchfile
|
||||||
|
- Navigate to the emulator folder of the project
|
||||||
|
- Source the qt binaries (qmake, gcc, g++) by executing
|
||||||
|
export PATH=$PATH:/c/Qt/Tools/mingw491_32/bin:/c/Qt/5.4/mingw491_32/bin
|
||||||
|
- navigate to libs/Pixy and execute make
|
||||||
|
- navigate back into the emulator folder and execute make
|
||||||
|
- this should generate you build/emulator.exe
|
||||||
|
|
||||||
|
Starting:
|
||||||
|
- Extract windows_dlls.rar to the build folder
|
||||||
|
- Copy the emulated folder into the build folder
|
||||||
|
- Make sure that you installed the pixy usb driver (e.g. by installing pixymon http://cmucam.org/projects/cmucam5/wiki/Latest_release)
|
||||||
|
- Start emulator.exe
|
||||||
|
|
||||||
|
Pitfalls:
|
||||||
|
- libstdc++ must be provided by qt. do not use one of msys or mingw. you will waste hours with debugging of the make process
|
||||||
|
|
||||||
|
Sources:
|
||||||
|
- libusb for windows was taken from https://github.com/charmedlabs/pixy/tree/master/src/host/windows
|
||||||
|
- Boost was compiled from sources, using http://andres.jaimes.net/718/how-to-install-the-c-boost-libraries-on-windows/ and http://www.boost.org/doc/libs/1_58_0/more/getting_started/windows.html
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<launchConfiguration type="org.eclipse.cdt.launch.applicationLaunchType">
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.AUTO_SOLIB" value="true"/>
|
|
||||||
<listAttribute key="org.eclipse.cdt.dsf.gdb.AUTO_SOLIB_LIST"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="gdb"/>
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_ON_FORK" value="false"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.GDB_INIT" value=".gdbinit"/>
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.NON_STOP" value="false"/>
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.REVERSE" value="false"/>
|
|
||||||
<listAttribute key="org.eclipse.cdt.dsf.gdb.SOLIB_PATH"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.TRACEPOINT_MODE" value="TP_NORMAL_ONLY"/>
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/>
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.internal.ui.launching.LocalApplicationCDebuggerTab.DEFAULTS_SET" value="true"/>
|
|
||||||
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_ID" value="gdb"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="run"/>
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="true"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="build/emulator"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="discoverpixy emulator"/>
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/>
|
|
||||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="cdt.managedbuild.toolchain.gnu.base.1806077868"/>
|
|
||||||
<booleanAttribute key="org.eclipse.cdt.launch.use_terminal" value="true"/>
|
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
|
||||||
<listEntry value="/discoverpixy emulator"/>
|
|
||||||
</listAttribute>
|
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
|
||||||
<listEntry value="4"/>
|
|
||||||
</listAttribute>
|
|
||||||
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList context="reserved-for-future-use"/> "/>
|
|
||||||
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
|
|
||||||
</launchConfiguration>
|
|
||||||
BIN
emulator/windows_dlls.rar
Normal file
BIN
emulator/windows_dlls.rar
Normal file
Binary file not shown.
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
echo "/**************************************************************************************************************************************"
|
echo "/**************************************************************************************************************************************"
|
||||||
echo "* Project: discoverpixy"
|
echo "* Project: discoverpixy"
|
||||||
echo "* Website: https://github.com/t-moe/discoverpixy"
|
|
||||||
echo "* Authors: Aaron Schmocker, Timo Lang"
|
echo "* Authors: Aaron Schmocker, Timo Lang"
|
||||||
echo "* Institution: BFH Bern University of Applied Sciences"
|
echo "* Institution: BFH Bern University of Applied Sciences"
|
||||||
echo "* File: $1"
|
echo "* File: $1"
|
||||||
|
|||||||
Reference in New Issue
Block a user