/*********************************************************************************/ /** * File: dvoraj42.h * Author: Jan Dvorak z Vozerovic * FEL-ID: dvoraj42 * e-mail: dvorkaman@gmail.com * site: dvorkaman.php5.cz */ #ifndef __dvoraj42_h__ #define __dvoraj42_h__ #ifdef __cplusplus extern "C" { #endif #include "stdint.h" /*********************************************************************************/ /** * Defines */ #define LCD_WIDTH 128 #define LCD_HEIGHT 64 #define LCD_PAGE_SIZE 8 #define LCD_BUTTON_WIDTH 32 #define LCD_BUTTON_HEIGHT 16 #define ENCODER_MIDDLE 0x1 << 16 // 2^16 #define ENCODER_BITS_PER_TICK 2 // value changes 2^2 per one tick #define LETTER_WIDTH 5 // in pixels #define ACCELEROMETER_VALUE_SHIFT 6 // how much lower bits to cut #define ACCELEROMETER_MIN_VAL 10 // minimal treshold for user #define ACCELEROMETER_MAX_VAL 300 // maximal treshold for user #define ACCELEROMETER_MAX_VALUES 1000 #define FLASH_PREAMB 0x3598 // to ensure data consistency #define FLASH_START 0x08020000 // from #define FLASH_END 0x080A0000 // to #define FLASH_START_SECTOR FLASH_Sector_5 // from sector #define FLASH_END_SECTOR FLASH_Sector_9 // to sector /*********************************************************************************/ /** * Structures */ typedef struct { int button1; int button2; int pressed; // detection wheter button is pressed (for second type of input) int direction; // encoder detection + - 1 }input; typedef struct // 64b { uint16_t preambule; // 0x3598 uint16_t accelMinValue; int16_t calibrationX; // signed version of number int16_t calibrationY; }settings; typedef struct // 96b { uint16_t preambule; // 0x3598 uint32_t brokenAtTime; uint16_t measuredValuesCount; uint32_t systemTime; }materialInfo; typedef struct // 64b { uint32_t time; int32_t value; }data; /*********************************************************************************/ /** * Headers */ void LCDDrawFullImage(uint8_t image[]); void LCDDrawImage(uint8_t image[], int offsetX, int offsetY, int width, int height); void LCDDrawButton(uint8_t image[], int x, int y); void LCDMergeImages(uint8_t source[], uint8_t mergeWith[]); void ConvertBitmapToLCDImage(uint8_t bitmap[], uint8_t image[], int width, int height); void LCDPrintString(char *string, int x, int row); void LCDPrintNumber(int number, int digits, int x, int row); void LCDShowTime(int seconds); void LCDSetPixel(uint8_t image[], int x, int y, int value); void LCDShowMeasuredValues(uint32_t timeOffset, int zoom); int getButton1State(); int getButton2State(); void initializeEncoder(); void handleEncoderPosition(int pin); int getEncoderPosition(); int getEncoderDirection(); unsigned int getEncoderTicks(); void initializeAccelerometer(void); int convertMeasuredAccelerometer(unsigned int value); void handleAccelerometerData(void); void setMaterialBroken(void); void delayCycles(unsigned int cycles); int bitmapGetPixelAt(uint8_t bitmap[], int x, int y, int width); void bitmapSetPixelAt(uint8_t bitmap[], int value, int x, int y, int width); void drawActualState(void); input readInput(int allowPress); void initializeFLASH(); void FLASHRestoreToDefault(void); void FLASHLoadData(void); void FLASHSaveData(void); void FLASHErase(void); void clearMearusedData(void); void convertSecToTime(int seconds, char* outputMinSec, char* outputHour); /*********************************************************************************/ #ifdef __cplusplus } #endif #endif