[sky9x] Massstorage (not finished at all!)

[stock] 180bytes flash saved
This commit is contained in:
bsongis
2012-09-11 19:58:49 +00:00
parent 91fbcb94d7
commit fcf6f436b0
702 changed files with 166014 additions and 441 deletions
@@ -0,0 +1,66 @@
#include "sam-gui/common/sam_gui_bitmap_raw.h"
#include "sam-gui/common/sam_gui_errors.h"
#include <stdlib.h>
#include <string.h>
extern int BitmapRaw_Initialize( SGUIBitmapRaw* pbmpBitmap, uint32_t dwWidth, uint32_t dwHeight, uint32_t dwBPP )
{
// Check pointers
if ( pbmpBitmap == NULL )
{
return SAMGUI_E_BAD_POINTER ;
}
// Check parameters consistency
if ( (dwWidth == 0) || (dwHeight == 0) || (dwBPP == 0) )
{
return SAMGUI_E_BAD_PARAMETER ;
}
memset( pbmpBitmap, 0, sizeof( SGUIBitmapRaw ) ) ;
pbmpBitmap->dwWidth=dwWidth ;
pbmpBitmap->dwHeight=dwHeight ;
pbmpBitmap->dwBPP=dwBPP ;
return SAMGUI_E_OK ;
}
extern int BitmapRaw_SetData( SGUIBitmapRaw* pbmpBitmap, uint8_t* pucData, uint32_t dwDataLength )
{
// Check pointers
if ( (pbmpBitmap == NULL) || (pucData == NULL) )
{
return SAMGUI_E_BAD_POINTER ;
}
// Check parameters consistency
if ( dwDataLength == 0 )
{
return SAMGUI_E_BAD_PARAMETER ;
}
pbmpBitmap->pucData=pucData ;
pbmpBitmap->dwDataLength=dwDataLength ;
return SAMGUI_E_OK ;
}
extern int BitmapRaw_SetLUT( SGUIBitmapRaw* pbmpBitmap, uint8_t* pucLUT, uint32_t dwLUTLength )
{
// Check pointers
if ( (pbmpBitmap == NULL) || (pucLUT == NULL) )
{
return SAMGUI_E_BAD_POINTER ;
}
// Check parameters consistency
if ( dwLUTLength == 0 )
{
return SAMGUI_E_BAD_PARAMETER ;
}
pbmpBitmap->pucData=pucLUT ;
pbmpBitmap->dwDataLength=dwLUTLength ;
return SAMGUI_E_OK ;
}
@@ -0,0 +1,20 @@
#ifndef _SAM_GUI_BITMAP_RAW_
#define _SAM_GUI_BITMAP_RAW_
typedef struct _SGUIBitmapRaw
{
uint32_t dwWidth ;
uint32_t dwHeight ;
uint32_t dwBPP ;
uint32_t dwLUTLength ;
uint8_t* pucLUT ;
uint32_t dwDataLength ;
uint8_t* pucData ;
} SGUIBitmapRaw ;
extern int BitmapRaw_Initialize( SGUIBitmapRaw* pbmpBitmap, uint32_t dwWidth, uint32_t dwHeight, uint32_t dwBPP ) ;
extern int BitmapRaw_SetData( SGUIBitmapRaw* pbmpBitmap, uint8_t* pucData, uint32_t dwDataLength ) ;
extern int BitmapRaw_SetLUT( SGUIBitmapRaw* pbmpBitmap, uint8_t* pucLUT, uint32_t dwLUTLength ) ;
#endif // _SAM_GUI_BITMAP_RAW_
@@ -0,0 +1,39 @@
#include "sam-gui/common/sam_gui_color.h"
#include "sam-gui/common/sam_gui_errors.h"
#include <stdlib.h>
extern int COLOR_GetGradientValue( SGUIColor* pclrBegin, SGUIColor* pclrEnd,
uint32_t dwNumber, uint32_t dwIndex, SGUIColor* pclrResult )
{
// Check pointers
if ( (pclrBegin == NULL) || (pclrEnd == NULL) || (pclrResult == NULL) )
{
return SAMGUI_E_BAD_POINTER ;
}
// Check parameters consistency
if ( dwNumber == 0 )
{
return SAMGUI_E_BAD_POINTER ;
}
// Process gradient
return SAMGUI_E_OK ;
}
extern int COLOR_RGB565( SGUIColor* pclrIn, SGUIColor* pclrResult )
{
// Check pointers
if ( (pclrIn == NULL) || (pclrResult == NULL) )
{
return SAMGUI_E_BAD_POINTER ;
}
pclrResult->u.RGBA.ucR=pclrIn->u.RGBA.ucR&0x1f ;
pclrResult->u.RGBA.ucG=pclrIn->u.RGBA.ucG&0x3f ;
pclrResult->u.RGBA.ucB=pclrIn->u.RGBA.ucB&0x1f ;
pclrResult->u.RGBA.ucA=0x00 ;
return SAMGUI_E_OK ;
}
@@ -0,0 +1,32 @@
#ifndef _SAM_GUI_COLOR_
#define _SAM_GUI_COLOR_
typedef struct _SGUIColor
{
union _u
{
uint32_t dwRGBA ;
struct _RGBA
{
uint8_t ucA ;
uint8_t ucB ;
uint8_t ucG ;
uint8_t ucR ;
} RGBA ;
} u ;
} SGUIColor ;
//#define ucR u.RGBA.ucR
//#define ucG u.RGBA.ucG
//#define ucB u.RGBA.ucB
//#define ucA u.RGBA.ucA
extern int COLOR_GetGradientValue( SGUIColor* pclrBegin, SGUIColor* pclrEnd,
uint32_t dwNumber, uint32_t dwIndex, SGUIColor* pclrResult ) ;
extern int COLOR_RGB565( SGUIColor* pclrIn, SGUIColor* pclrResult ) ;
//#define COLOR_FROM_RGB( r, g, b )
#endif // _SAM_GUI_COLOR_
@@ -0,0 +1,2 @@
#include "sam-gui/common/sam_gui_color.h"
@@ -0,0 +1,45 @@
#include "sam-gui/common/sam_gui_color.h"
#define GUICLR_WHITE 0x00ffffff
#define GUICLR_BLACK 0x00000000
#define GUICLR_BLUE 0x0000FF
#define GUICLR_GREEN 0x00FF00
#define GUICLR_RED 0xFF0000
#define GUICLR_NAVY 0x000080
#define GUICLR_DARKBLUE 0x00008B
#define GUICLR_DARKGREEN 0x006400
#define GUICLR_DARKCYAN 0x008B8B
#define GUICLR_CYAN 0x00FFFF
#define GUICLR_TURQUOISE 0x40E0D0
#define GUICLR_INDIGO 0x4B0082
#define GUICLR_DARKRED 0x800000
#define GUICLR_OLIVE 0x808000
#define GUICLR_GRAY 0x808080
#define GUICLR_SKYBLUE 0x87CEEB
#define GUICLR_BLUEVIOLET 0x8A2BE2
#define GUICLR_LIGHTGREEN 0x90EE90
#define GUICLR_DARKVIOLET 0x9400D3
#define GUICLR_YELLOWGREEN 0x9ACD32
#define GUICLR_BROWN 0xA52A2A
#define GUICLR_DARKGRAY 0xA9A9A9
#define GUICLR_SIENNA 0xA0522D
#define GUICLR_LIGHTBLUE 0xADD8E6
#define GUICLR_GREENYELLOW 0xADFF2F
#define GUICLR_SILVER 0xC0C0C0
#define GUICLR_LIGHTGREY 0xD3D3D3
#define GUICLR_LIGHTCYAN 0xE0FFFF
#define GUICLR_VIOLET 0xEE82EE
#define GUICLR_AZUR 0xF0FFFF
#define GUICLR_BEIGE 0xF5F5DC
#define GUICLR_MAGENTA 0xFF00FF
#define GUICLR_TOMATO 0xFF6347
#define GUICLR_GOLD 0xFFD700
#define GUICLR_ORANGE 0xFFA500
#define GUICLR_SNOW 0xFFFAFA
#define GUICLR_YELLOW 0xFFFF00
#define GUICLR( r, g, b ) ((uint32_t)((r<<16)|(g<<8)|b))
#define GUICLR_ATMEL_BLUE GUICLR( 6, 61, 232 )
@@ -0,0 +1,42 @@
#ifndef _SAM_GUI_ERRORS_
#define _SAM_GUI_ERRORS_
#define SAMGUI_E_OK 0x0L
#define SAMGUI_ERRORS_COMMON_BASE 0x1L
#define SAMGUI_ERRORS_PORTING_BASE 0x1000L
#define SAMGUI_ERRORS_DISP_BASE 0x2000L
#define SAMGUI_ERRORS_WGT_BASE 0x3000L
#define SAMGUI_ERRORS_WM_BASE 0x4000L
/*
* Common errors
*/
#define SAMGUI_E_BAD_POINTER SAMGUI_ERRORS_COMMON_BASE
#define SAMGUI_E_BAD_PARAMETER SAMGUI_ERRORS_COMMON_BASE+1
#define SAMGUI_E_FILE_OPEN SAMGUI_ERRORS_COMMON_BASE+2
/*
* Porting layer errors
*/
/*
* DISP layer errors
*/
#define SAMGUI_E_WRONG_COMPONENT SAMGUI_ERRORS_DISP_BASE
/*
* WGT layer errors
*/
#define SAMGUI_E_TOO_MUCH_WIDGETS SAMGUI_ERRORS_WGT_BASE
#define SAMGUI_E_MSQUEUE SAMGUI_ERRORS_WGT_BASE+1
#define SAMGUI_E_NO_SELECTED_WIDGET SAMGUI_ERRORS_WGT_BASE+2
#define SAMGUI_E_NOT_ENOUGH_MEMORY SAMGUI_ERRORS_WGT_BASE+3
#define SAMGUI_E_INVALID_WIDGET SAMGUI_ERRORS_WGT_BASE+4
/*
* WM layer errors
*/
#endif // _SAM_GUI_ERRORS_
@@ -0,0 +1,11 @@
#include "sam-gui/common/sam_gui_font.h"
#include "sam-gui/common/sam_gui_errors.h"
#include <stdlib.h>
const SGUIFont g_Font10x14=
{
.dwType=WGT_FONT_TYPE_BITMAP,
.dwWidth=10 ,
.dwHeight=14 ,
.pvData=(void*)aucFont10x14
} ;
@@ -0,0 +1,23 @@
#ifndef _SAM_GUI_FONT_
#define _SAM_GUI_FONT_
#include "sam-gui/common/sam_gui_font10x14.h"
typedef enum _WGT_FontType
{
WGT_FONT_TYPE_BITMAP,
WGT_FONT_TYPE_VECTOR,
WGT_FONT_TYPE_MAX
} WGT_FontType ;
typedef struct _SGUIFont
{
WGT_FontType dwType ;
uint32_t dwWidth ; // Font width in pixels.
uint32_t dwHeight ; // Font height in pixels.
void* pvData ;
} SGUIFont ;
extern const SGUIFont g_Font10x14 ;
#endif // _SAM_GUI_FONT_
@@ -0,0 +1,235 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
/**
* \file
*
* Font 10x14 table definition.
*
*/
#include "sam-gui/common/sam_gui_font10x14.h"
/** Char set of font 10x14 */
const uint8_t aucFont10x14[]=
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xCC,
0xFF, 0xCC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0xF0, 0x00, 0x00, 0x00,
0x00, 0x00, 0xF0, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0C, 0xC0, 0x0C, 0xC0, 0xFF, 0xFC, 0xFF, 0xFC, 0x0C, 0xC0,
0x0C, 0xC0, 0xFF, 0xFC, 0xFF, 0xFC, 0x0C, 0xC0, 0x0C, 0xC0,
0x0C, 0x60, 0x1E, 0x70, 0x3F, 0x30, 0x33, 0x30, 0xFF, 0xFC,
0xFF, 0xFC, 0x33, 0x30, 0x33, 0xF0, 0x39, 0xE0, 0x18, 0xC0,
0x60, 0x00, 0xF0, 0x0C, 0xF0, 0x3C, 0x60, 0xF0, 0x03, 0xC0,
0x0F, 0x00, 0x3C, 0x18, 0xF0, 0x3C, 0xC0, 0x3C, 0x00, 0x18,
0x3C, 0xF0, 0x7F, 0xF8, 0xC3, 0x1C, 0xC7, 0x8C, 0xCF, 0xCC,
0xDC, 0xEC, 0x78, 0x78, 0x30, 0x30, 0x00, 0xFC, 0x00, 0xCC,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x00, 0xEC, 0x00,
0xF8, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0F, 0xC0, 0x3F, 0xF0, 0x78, 0x78,
0x60, 0x18, 0xC0, 0x0C, 0xC0, 0x0C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xC0, 0x0C, 0xC0, 0x0C, 0x60, 0x18,
0x78, 0x78, 0x3F, 0xF0, 0x0F, 0xC0, 0x00, 0x00, 0x00, 0x00,
0x0C, 0x60, 0x0E, 0xE0, 0x07, 0xC0, 0x03, 0x80, 0x3F, 0xF8,
0x3F, 0xF8, 0x03, 0x80, 0x07, 0xC0, 0x0E, 0xE0, 0x0C, 0x60,
0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x3F, 0xF0,
0x3F, 0xF0, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00,
0x00, 0x44, 0x00, 0xEC, 0x00, 0xF8, 0x00, 0x70, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00,
0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00,
0x00, 0x18, 0x00, 0x3C, 0x00, 0x3C, 0x00, 0x18, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0C, 0x00, 0x3C, 0x00, 0xF0, 0x03, 0xC0,
0x0F, 0x00, 0x3C, 0x00, 0xF0, 0x00, 0xC0, 0x00, 0x00, 0x00,
0x3F, 0xF0, 0x7F, 0xF8, 0xE0, 0xFC, 0xC1, 0xCC, 0xC3, 0x8C,
0xC7, 0x0C, 0xCE, 0x0C, 0xFC, 0x1C, 0x7F, 0xF8, 0x3F, 0xF0,
0x00, 0x00, 0x00, 0x00, 0x30, 0x0C, 0x70, 0x0C, 0xFF, 0xFC,
0xFF, 0xFC, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
0x30, 0x0C, 0x70, 0x1C, 0xE0, 0x3C, 0xC0, 0x7C, 0xC0, 0xEC,
0xC1, 0xCC, 0xC3, 0x8C, 0xE7, 0x0C, 0x7E, 0x0C, 0x3C, 0x0C,
0x30, 0x30, 0x70, 0x38, 0xE0, 0x1C, 0xC0, 0x0C, 0xC0, 0x0C,
0xC3, 0x0C, 0xC3, 0x0C, 0xE3, 0x1C, 0x7F, 0xF8, 0x3C, 0xF0,
0x03, 0xC0, 0x07, 0xC0, 0x0E, 0xC0, 0x1C, 0xC0, 0x38, 0xC0,
0x70, 0xC0, 0xFF, 0xFC, 0xFF, 0xFC, 0x00, 0xC0, 0x00, 0xC0,
0xFC, 0x30, 0xFC, 0x38, 0xCC, 0x1C, 0xCC, 0x0C, 0xCC, 0x0C,
0xCC, 0x0C, 0xCC, 0x0C, 0xCE, 0x1C, 0xC7, 0xF8, 0xC3, 0xF0,
0x3F, 0xF0, 0x7F, 0xF8, 0xE3, 0x1C, 0xC3, 0x0C, 0xC3, 0x0C,
0xC3, 0x0C, 0xC3, 0x0C, 0xE3, 0x9C, 0x71, 0xF8, 0x30, 0xF0,
0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC3, 0xFC,
0xC7, 0xFC, 0xCE, 0x00, 0xDC, 0x00, 0xF8, 0x00, 0xF0, 0x00,
0x3C, 0xF0, 0x7F, 0xF8, 0xE7, 0x9C, 0xC3, 0x0C, 0xC3, 0x0C,
0xC3, 0x0C, 0xC3, 0x0C, 0xE7, 0x9C, 0x7F, 0xF8, 0x3C, 0xF0,
0x3C, 0x00, 0x7E, 0x00, 0xE7, 0x0C, 0xC3, 0x0C, 0xC3, 0x1C,
0xC3, 0x38, 0xC3, 0x70, 0xE7, 0xE0, 0x7F, 0xC0, 0x3F, 0x80,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x60, 0x3C, 0xF0,
0x3C, 0xF0, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x44, 0x3C, 0xEC,
0x3C, 0xF8, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x03, 0x00, 0x07, 0x80, 0x0F, 0xC0, 0x1C, 0xE0,
0x38, 0x70, 0x70, 0x38, 0xE0, 0x1C, 0xC0, 0x0C, 0x00, 0x00,
0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0,
0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0,
0x00, 0x00, 0xC0, 0x0C, 0xE0, 0x1C, 0x70, 0x38, 0x38, 0x70,
0x1C, 0xE0, 0x0F, 0xC0, 0x07, 0x80, 0x03, 0x00, 0x00, 0x00,
0x30, 0x00, 0x70, 0x00, 0xE0, 0x00, 0xC0, 0x00, 0xC1, 0xEC,
0xC3, 0xEC, 0xC3, 0x00, 0xE6, 0x00, 0x7E, 0x00, 0x3C, 0x00,
0x30, 0xF0, 0x71, 0xF8, 0xE3, 0x9C, 0xC3, 0x0C, 0xC3, 0xFC,
0xC3, 0xFC, 0xC0, 0x0C, 0xE0, 0x1C, 0x7F, 0xF8, 0x3F, 0xF0,
0x3F, 0xFC, 0x7F, 0xFC, 0xE0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0,
0xC0, 0xC0, 0xC0, 0xC0, 0xE0, 0xC0, 0x7F, 0xFC, 0x3F, 0xFC,
0xFF, 0xFC, 0xFF, 0xFC, 0xC3, 0x0C, 0xC3, 0x0C, 0xC3, 0x0C,
0xC3, 0x0C, 0xC3, 0x0C, 0xE7, 0x9C, 0x7F, 0xF8, 0x3C, 0xF0,
0x3F, 0xF0, 0x7F, 0xF8, 0xE0, 0x1C, 0xC0, 0x0C, 0xC0, 0x0C,
0xC0, 0x0C, 0xC0, 0x0C, 0xE0, 0x1C, 0x70, 0x38, 0x30, 0x30,
0xFF, 0xFC, 0xFF, 0xFC, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C,
0xC0, 0x0C, 0xC0, 0x0C, 0xE0, 0x1C, 0x7F, 0xF8, 0x3F, 0xF0,
0xFF, 0xFC, 0xFF, 0xFC, 0xC3, 0x0C, 0xC3, 0x0C, 0xC3, 0x0C,
0xC3, 0x0C, 0xC3, 0x0C, 0xC3, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C,
0xFF, 0xFC, 0xFF, 0xFC, 0xC3, 0x00, 0xC3, 0x00, 0xC3, 0x00,
0xC3, 0x00, 0xC3, 0x00, 0xC3, 0x00, 0xC0, 0x00, 0xC0, 0x00,
0x3F, 0xF0, 0x7F, 0xF8, 0xE0, 0x1C, 0xC0, 0x0C, 0xC0, 0x0C,
0xC3, 0x0C, 0xC3, 0x0C, 0xE3, 0x1C, 0x73, 0xF8, 0x33, 0xF0,
0xFF, 0xFC, 0xFF, 0xFC, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00,
0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0xFF, 0xFC, 0xFF, 0xFC,
0x00, 0x00, 0x00, 0x00, 0xC0, 0x0C, 0xC0, 0x0C, 0xFF, 0xFC,
0xFF, 0xFC, 0xC0, 0x0C, 0xC0, 0x0C, 0x00, 0x00, 0x00, 0x00,
0x00, 0x30, 0x00, 0x38, 0xC0, 0x1C, 0xC0, 0x0C, 0xC0, 0x0C,
0xC0, 0x1C, 0xFF, 0xF8, 0xFF, 0xF0, 0xC0, 0x00, 0xC0, 0x00,
0xFF, 0xFC, 0xFF, 0xFC, 0x07, 0x80, 0x07, 0x80, 0x0F, 0xC0,
0x1C, 0xE0, 0x38, 0x70, 0x70, 0x38, 0xE0, 0x1C, 0xC0, 0x0C,
0xFF, 0xFC, 0xFF, 0xFC, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C,
0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C,
0xFF, 0xFC, 0xFF, 0xFC, 0x70, 0x00, 0x38, 0x00, 0x1F, 0x00,
0x1F, 0x00, 0x38, 0x00, 0x70, 0x00, 0xFF, 0xFC, 0xFF, 0xFC,
0xFF, 0xFC, 0xFF, 0xFC, 0x1C, 0x00, 0x0E, 0x00, 0x07, 0x00,
0x03, 0x80, 0x01, 0xC0, 0x00, 0xE0, 0xFF, 0xFC, 0xFF, 0xFC,
0x3F, 0xF0, 0x7F, 0xF8, 0xE0, 0x1C, 0xC0, 0x0C, 0xC0, 0x0C,
0xC0, 0x0C, 0xC0, 0x0C, 0xE0, 0x1C, 0x7F, 0xF8, 0x3F, 0xF0,
0xFF, 0xFC, 0xFF, 0xFC, 0xC3, 0x00, 0xC3, 0x00, 0xC3, 0x00,
0xC3, 0x00, 0xC3, 0x00, 0xE7, 0x00, 0x7E, 0x00, 0x3C, 0x00,
0x3F, 0xF0, 0x7F, 0xF8, 0xE0, 0x1C, 0xC0, 0x0C, 0xC0, 0xCC,
0xC0, 0xEC, 0xC0, 0x7C, 0xE0, 0x38, 0x7F, 0xFC, 0x3F, 0xEC,
0xFF, 0xFC, 0xFF, 0xFC, 0xC3, 0x00, 0xC3, 0x80, 0xC3, 0x80,
0xC3, 0xC0, 0xC3, 0xC0, 0xE7, 0x70, 0x7E, 0x3C, 0x3C, 0x1C,
0x3C, 0x18, 0x7E, 0x1C, 0xE7, 0x0C, 0xC3, 0x0C, 0xC3, 0x0C,
0xC3, 0x0C, 0xC3, 0x0C, 0xC3, 0x9C, 0xE1, 0xF8, 0x60, 0xF0,
0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xFF, 0xFC,
0xFF, 0xFC, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00,
0xFF, 0xF0, 0xFF, 0xF8, 0x00, 0x1C, 0x00, 0x0C, 0x00, 0x0C,
0x00, 0x0C, 0x00, 0x0C, 0x00, 0x1C, 0xFF, 0xF8, 0xFF, 0xF0,
0xFF, 0xC0, 0xFF, 0xE0, 0x00, 0x70, 0x00, 0x38, 0x00, 0x1C,
0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, 0xFF, 0xE0, 0xFF, 0xC0,
0xFF, 0xF0, 0xFF, 0xF8, 0x00, 0x1C, 0x00, 0x3C, 0x00, 0xF8,
0x00, 0xF8, 0x00, 0x3C, 0x00, 0x1C, 0xFF, 0xF8, 0xFF, 0xF0,
0xF0, 0x3C, 0xF8, 0x7C, 0x1C, 0xE0, 0x0F, 0xC0, 0x07, 0x80,
0x07, 0x80, 0x0F, 0xC0, 0x1C, 0xE0, 0xF8, 0x7C, 0xF0, 0x3C,
0xFC, 0x00, 0xFE, 0x00, 0x07, 0x00, 0x03, 0x80, 0x01, 0xFC,
0x01, 0xFC, 0x03, 0x80, 0x07, 0x00, 0xFE, 0x00, 0xFC, 0x00,
0xC0, 0x3C, 0xC0, 0x7C, 0xC0, 0xEC, 0xC1, 0xCC, 0xC3, 0x8C,
0xC7, 0x0C, 0xCE, 0x0C, 0xDC, 0x0C, 0xF8, 0x0C, 0xF0, 0x0C,
0x00, 0x00, 0x00, 0x00, 0xFF, 0xFC, 0xFF, 0xFC, 0xC0, 0x0C,
0xC0, 0x0C, 0xC0, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x30, 0x00, 0x30, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x03, 0x00,
0x03, 0x00, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0x30, 0x00, 0x30,
0x00, 0x00, 0x00, 0x00, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C,
0xFF, 0xFC, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0C, 0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, 0x00, 0xE0, 0x00,
0xE0, 0x00, 0x70, 0x00, 0x38, 0x00, 0x1C, 0x00, 0x0C, 0x00,
0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C,
0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x0C,
0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0xE0, 0x00, 0x70, 0x00,
0x38, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x30, 0x06, 0x78, 0x0E, 0xFC, 0x0C, 0xCC, 0x0C, 0xCC,
0x0C, 0xCC, 0x0C, 0xCC, 0x0E, 0xCC, 0x07, 0xFC, 0x03, 0xF8,
0xFF, 0xFC, 0xFF, 0xFC, 0x03, 0x0C, 0x03, 0x0C, 0x03, 0x0C,
0x03, 0x0C, 0x03, 0x0C, 0x03, 0x9C, 0x01, 0xF8, 0x00, 0xF0,
0x03, 0xF0, 0x07, 0xF8, 0x0E, 0x1C, 0x0C, 0x0C, 0x0C, 0x0C,
0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x1C, 0x07, 0x38, 0x03, 0x30,
0x00, 0xF0, 0x01, 0xF8, 0x03, 0x9C, 0x03, 0x0C, 0x03, 0x0C,
0x03, 0x0C, 0x03, 0x0C, 0x03, 0x0C, 0xFF, 0xFC, 0xFF, 0xFC,
0x03, 0xF0, 0x07, 0xF8, 0x0E, 0xDC, 0x0C, 0xCC, 0x0C, 0xCC,
0x0C, 0xCC, 0x0C, 0xCC, 0x0E, 0xDC, 0x07, 0xD8, 0x03, 0x90,
0x00, 0x00, 0x03, 0x00, 0x3F, 0xFC, 0x7F, 0xFC, 0xE3, 0x00,
0xE3, 0x00, 0x70, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0x18, 0x07, 0x9C, 0x0F, 0xCC, 0x0C, 0xCC, 0x0C, 0xCC,
0x0C, 0xCC, 0x0C, 0xCC, 0x0C, 0xDC, 0x0F, 0xF8, 0x07, 0xF0,
0xFF, 0xFC, 0xFF, 0xFC, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00,
0x03, 0x00, 0x03, 0x80, 0x01, 0xFC, 0x00, 0xFC, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0xFC,
0x1B, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x30, 0x00, 0x38, 0x00, 0x1C, 0x00, 0x0C,
0x00, 0x0C, 0x00, 0x1C, 0xCF, 0xF8, 0xCF, 0xF0, 0x00, 0x00,
0x00, 0x00, 0xFF, 0xFC, 0xFF, 0xFC, 0x00, 0xE0, 0x01, 0xE0,
0x03, 0xF0, 0x07, 0x38, 0x0E, 0x1C, 0x0C, 0x0C, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xC0, 0x0C, 0xC0, 0x0C, 0xFF, 0xFC,
0xFF, 0xFC, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
0x0F, 0xFC, 0x0F, 0xFC, 0x0E, 0x00, 0x07, 0x00, 0x03, 0xC0,
0x03, 0xC0, 0x07, 0x00, 0x0E, 0x00, 0x0F, 0xFC, 0x0F, 0xFC,
0x0F, 0xFC, 0x0F, 0xFC, 0x03, 0x00, 0x07, 0x00, 0x0E, 0x00,
0x0C, 0x00, 0x0C, 0x00, 0x0E, 0x00, 0x07, 0xFC, 0x03, 0xFC,
0x03, 0xF0, 0x07, 0xF8, 0x0E, 0x1C, 0x0C, 0x0C, 0x0C, 0x0C,
0x0C, 0x0C, 0x0C, 0x0C, 0x0E, 0x1C, 0x07, 0xF8, 0x03, 0xF0,
0x0F, 0xFC, 0x0F, 0xFC, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0,
0x0C, 0xC0, 0x0C, 0xC0, 0x0F, 0xC0, 0x07, 0x80, 0x03, 0x00,
0x03, 0x00, 0x07, 0x80, 0x0F, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0,
0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0F, 0xFC, 0x0F, 0xFC,
0x0F, 0xFC, 0x0F, 0xFC, 0x03, 0x80, 0x07, 0x00, 0x0E, 0x00,
0x0C, 0x00, 0x0C, 0x00, 0x0E, 0x00, 0x07, 0x00, 0x03, 0x00,
0x03, 0x18, 0x07, 0x9C, 0x0F, 0xCC, 0x0C, 0xCC, 0x0C, 0xCC,
0x0C, 0xCC, 0x0C, 0xCC, 0x0C, 0xFC, 0x0E, 0x78, 0x06, 0x30,
0x00, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0xFF, 0xF0, 0xFF, 0xF8,
0x0C, 0x1C, 0x0C, 0x1C, 0x0C, 0x38, 0x0C, 0x30, 0x00, 0x00,
0x0F, 0xF0, 0x0F, 0xF8, 0x00, 0x1C, 0x00, 0x0C, 0x00, 0x0C,
0x00, 0x0C, 0x00, 0x0C, 0x00, 0x1C, 0x0F, 0xF8, 0x0F, 0xF0,
0x0F, 0xC0, 0x0F, 0xE0, 0x00, 0x70, 0x00, 0x38, 0x00, 0x1C,
0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, 0x0F, 0xE0, 0x0F, 0xC0,
0x0F, 0xF0, 0x0F, 0xF8, 0x00, 0x1C, 0x00, 0x1C, 0x00, 0xF8,
0x00, 0xF8, 0x00, 0x1C, 0x00, 0x1C, 0x0F, 0xF8, 0x0F, 0xF0,
0x0C, 0x0C, 0x0E, 0x1C, 0x07, 0x38, 0x03, 0xF0, 0x01, 0xE0,
0x01, 0xE0, 0x03, 0xF0, 0x07, 0x38, 0x0E, 0x1C, 0x0C, 0x0C,
0x0C, 0x00, 0x0E, 0x00, 0x07, 0x0C, 0x03, 0x9C, 0x01, 0xF8,
0x01, 0xF0, 0x03, 0x80, 0x07, 0x00, 0x0E, 0x00, 0x0C, 0x00,
0x0C, 0x0C, 0x0C, 0x1C, 0x0C, 0x3C, 0x0C, 0x7C, 0x0C, 0xEC,
0x0D, 0xCC, 0x0F, 0x8C, 0x0F, 0x0C, 0x0E, 0x0C, 0x0C, 0x0C,
0x00, 0x00, 0x03, 0x00, 0x07, 0x80, 0x3F, 0xF0, 0x7C, 0xF8,
0xE0, 0x1C, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0x00, 0x00,
0x03, 0x0C, 0x03, 0x0C, 0x3F, 0xFC, 0x7F, 0xFC, 0xE3, 0x0C,
0xC3, 0x0C, 0xC0, 0x0C, 0xE0, 0x0C, 0x70, 0x0C, 0x30, 0x0C,
0x00, 0x00, 0xC0, 0x0C, 0xC0, 0x0C, 0xC0, 0x0C, 0xE0, 0x1C,
0x7C, 0xF8, 0x3F, 0xF0, 0x07, 0x80, 0x03, 0x00, 0x00, 0x00,
0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00,
0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00,
0xFF, 0xFC, 0xFF, 0xFC, 0xFF, 0xFC, 0xFF, 0xFC, 0xFF, 0xFC,
0xFF, 0xFC, 0xFF, 0xFC, 0xFF, 0xFC, 0xFF, 0xFC, 0xFF, 0xFC
} ;
@@ -0,0 +1,44 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
/**
* \file
*
* Font 10x14 table definition.
*
*/
#ifndef _SAMGUI_FONT_10x14_
#define _SAMGUI_FONT_10x14_
//! Char set of font 10x14
extern const uint8_t aucFont10x14[] ;
#endif // _SAMGUI_FONT_10x14_
@@ -0,0 +1,2 @@
#include "sam-gui/common/sam_gui_point.h"
#include "sam-gui/common/sam_gui_errors.h"
@@ -0,0 +1,10 @@
#ifndef _SAM_GUI_POINT_
#define _SAM_GUI_POINT_
typedef struct _SGUIPoint
{
uint32_t dwX ;
uint32_t dwY ;
} SGUIPoint ;
#endif // _SAM_GUI_POINT_
@@ -0,0 +1,3 @@
#include "sam-gui/common/sam_gui_size.h"
#include "sam-gui/common/sam_gui_errors.h"
#include "sam-gui/common/sam_gui_point.h"
@@ -0,0 +1,12 @@
#ifndef _SAM_GUI_SIZE_
#define _SAM_GUI_SIZE_
#include "common/sam_gui_point.h"
typedef struct _SGUISize
{
uint32_t dwWidth ;
uint32_t dwHeight ;
} SGUISize ;
#endif // _SAM_GUI_SIZE_
@@ -0,0 +1,411 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2008, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
//------------------------------------------------------------------------------
/// \unit
///
/// !Purpose
///
/// HX8347 driver
///
/// !Usage
///
/// Explanation on the usage of the code made available through the header file.
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include <board.h>
#include <stdio.h>
#include "disp/backends/HX8347/backend_HX8347.h"
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
typedef volatile unsigned short REG16;
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
/// LCD index register address
#define HX8347_IR(baseAddr) (*((REG16 *)(baseAddr)))
/// LCD status register address
#define HX8347_SR(baseAddr) (*((REG16 *)(baseAddr)))
/// LCD data address
#define HX8347_D(baseAddr) (*((REG16 *)((unsigned int)(baseAddr) + BOARD_LCD_RS)))
/// HX8347 ID code
#define HX8347_HIMAXID_CODE 0x47
/// HX8347 LCD Registers
#define HX8347_R00H 0x00
#define HX8347_R01H 0x01
#define HX8347_R02H 0x02
#define HX8347_R03H 0x03
#define HX8347_R04H 0x04
#define HX8347_R05H 0x05
#define HX8347_R06H 0x06
#define HX8347_R07H 0x07
#define HX8347_R08H 0x08
#define HX8347_R09H 0x09
#define HX8347_R0AH 0x0A
#define HX8347_R0CH 0x0C
#define HX8347_R0DH 0x0D
#define HX8347_R0EH 0x0E
#define HX8347_R0FH 0x0F
#define HX8347_R10H 0x10
#define HX8347_R11H 0x11
#define HX8347_R12H 0x12
#define HX8347_R13H 0x13
#define HX8347_R14H 0x14
#define HX8347_R15H 0x15
#define HX8347_R16H 0x16
#define HX8347_R18H 0x18
#define HX8347_R19H 0x19
#define HX8347_R1AH 0x1A
#define HX8347_R1BH 0x1B
#define HX8347_R1CH 0x1C
#define HX8347_R1DH 0x1D
#define HX8347_R1EH 0x1E
#define HX8347_R1FH 0x1F
#define HX8347_R20H 0x20
#define HX8347_R21H 0x21
#define HX8347_R22H 0x22
#define HX8347_R23H 0x23
#define HX8347_R24H 0x24
#define HX8347_R25H 0x25
#define HX8347_R26H 0x26
#define HX8347_R27H 0x27
#define HX8347_R28H 0x28
#define HX8347_R29H 0x29
#define HX8347_R2AH 0x2A
#define HX8347_R2BH 0x2B
#define HX8347_R2CH 0x2C
#define HX8347_R2DH 0x2D
#define HX8347_R35H 0x35
#define HX8347_R36H 0x36
#define HX8347_R37H 0x37
#define HX8347_R38H 0x38
#define HX8347_R39H 0x39
#define HX8347_R3AH 0x3A
#define HX8347_R3BH 0x3B
#define HX8347_R3CH 0x3C
#define HX8347_R3DH 0x3D
#define HX8347_R3EH 0x3E
#define HX8347_R40H 0x40
#define HX8347_R41H 0x41
#define HX8347_R42H 0x42
#define HX8347_R43H 0x43
#define HX8347_R44H 0x44
#define HX8347_R45H 0x45
#define HX8347_R46H 0x46
#define HX8347_R47H 0x47
#define HX8347_R48H 0x48
#define HX8347_R49H 0x49
#define HX8347_R4AH 0x4A
#define HX8347_R4BH 0x4B
#define HX8347_R4CH 0x4C
#define HX8347_R4DH 0x4D
#define HX8347_R4EH 0x4E
#define HX8347_R4FH 0x4F
#define HX8347_R50H 0x50
#define HX8347_R51H 0x51
#define HX8347_R64H 0x64
#define HX8347_R65H 0x65
#define HX8347_R66H 0x66
#define HX8347_R67H 0x67
#define HX8347_R70H 0x70
#define HX8347_R72H 0x72
#define HX8347_R90H 0x90
#define HX8347_R91H 0x91
#define HX8347_R93H 0x93
#define HX8347_R94H 0x94
#define HX8347_R95H 0x95
//------------------------------------------------------------------------------
// External functions
//------------------------------------------------------------------------------
// External delay 1 ms function
extern void DelayMS(unsigned int ms);
#define Delay(ms) DelayMS(ms)
//------------------------------------------------------------------------------
// Global functions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Write data to LCD Register.
/// \param pLcdBase LCD base address.
/// \param reg Register address.
/// \param data Data to be written.
//------------------------------------------------------------------------------
static void _HX8347_WriteReg(void *pLcdBase, unsigned char reg, unsigned short data)
{
HX8347_IR(pLcdBase) = reg;
HX8347_D(pLcdBase) = data;
}
//------------------------------------------------------------------------------
/// Read data from LCD Register.
/// \param pLcdBase LCD base address.
/// \param reg Register address.
/// \return data Data to be read.
//------------------------------------------------------------------------------
static unsigned short _HX8347_ReadReg(void *pLcdBase, unsigned char reg)
{
HX8347_IR(pLcdBase) = reg;
return HX8347_D(pLcdBase);
}
//------------------------------------------------------------------------------
/// Read LCD status Register.
/// \param pLcdBase LCD base address.
/// \param reg Register address.
/// \return data Status Data.
//------------------------------------------------------------------------------
static unsigned short _HX8347_ReadStatus(void *pLcdBase)
{
return HX8347_SR(pLcdBase);
}
//------------------------------------------------------------------------------
/// Prepare to write GRAM data.
/// \param pLcdBase LCD base address.
//------------------------------------------------------------------------------
static void _HX8347_WriteRAM_Prepare(void *pLcdBase)
{
HX8347_IR(pLcdBase) = HX8347_R22H;
}
//------------------------------------------------------------------------------
/// Write data to LCD GRAM.
/// \param pLcdBase LCD base address.
/// \param color 16-bits RGB color.
//------------------------------------------------------------------------------
static void _HX8347_WriteRAM(void *pLcdBase, unsigned short color)
{
// Write 16-bit GRAM Reg
HX8347_D(pLcdBase) = color;
}
//------------------------------------------------------------------------------
/// Prepare to read GRAM data.
/// \param pLcdBase LCD base address.
//------------------------------------------------------------------------------
static void _HX8347_ReadRAM_Prepare(void *pLcdBase)
{
HX8347_IR(pLcdBase) = HX8347_R22H;
}
//------------------------------------------------------------------------------
/// Read GRAM data.
/// \param pLcdBase LCD base address.
/// \return 16-bits RGB color.
//------------------------------------------------------------------------------
static unsigned short _HX8347_ReadRAM(void *pLcdBase)
{
// Read 16-bit GRAM Reg
return HX8347_D(pLcdBase);
}
//------------------------------------------------------------------------------
/// Initialize the LCD controller.
/// \param pLcdBase LCD base address.
//------------------------------------------------------------------------------
static void _HX8347_Initialize(void *pLcdBase)
{
unsigned short chipid;
// Check HX8347 chipid
chipid = _HX8347_ReadReg(pLcdBase, HX8347_R67H);
if(chipid != HX8347_HIMAXID_CODE) {
printf("Read HX8347 chip ID error, skip initialization.\r\n");
return ;
}
// Start internal OSC
_HX8347_WriteReg(pLcdBase, HX8347_R19H, 0x49); // OSCADJ=10 0000, OSD_EN=1 //60Hz
_HX8347_WriteReg(pLcdBase, HX8347_R93H, 0x0C); // RADJ=1100
// Power on flow
_HX8347_WriteReg(pLcdBase, HX8347_R44H, 0x4D); // VCM=100 1101
_HX8347_WriteReg(pLcdBase, HX8347_R45H, 0x11); // VDV=1 0001
_HX8347_WriteReg(pLcdBase, HX8347_R20H, 0x40); // BT=0100
_HX8347_WriteReg(pLcdBase, HX8347_R1DH, 0x07); // VC1=111
_HX8347_WriteReg(pLcdBase, HX8347_R1EH, 0x00); // VC3=000
_HX8347_WriteReg(pLcdBase, HX8347_R1FH, 0x04); // VRH=0100
_HX8347_WriteReg(pLcdBase, HX8347_R1CH, 0x04); // AP=100
_HX8347_WriteReg(pLcdBase, HX8347_R1BH, 0x10); // GASENB=0, PON=1, DK=0, XDK=0, DDVDH_TRI=0, STB=0
Delay(50);
_HX8347_WriteReg(pLcdBase, HX8347_R43H, 0x80); // Set VCOMG=1
Delay(50);
// Gamma for CMO 2.8
_HX8347_WriteReg(pLcdBase, HX8347_R46H, 0x95);
_HX8347_WriteReg(pLcdBase, HX8347_R47H, 0x51);
_HX8347_WriteReg(pLcdBase, HX8347_R48H, 0x00);
_HX8347_WriteReg(pLcdBase, HX8347_R49H, 0x36);
_HX8347_WriteReg(pLcdBase, HX8347_R4AH, 0x11);
_HX8347_WriteReg(pLcdBase, HX8347_R4BH, 0x66);
_HX8347_WriteReg(pLcdBase, HX8347_R4CH, 0x14);
_HX8347_WriteReg(pLcdBase, HX8347_R4DH, 0x77);
_HX8347_WriteReg(pLcdBase, HX8347_R4EH, 0x13);
_HX8347_WriteReg(pLcdBase, HX8347_R4FH, 0x4C);
_HX8347_WriteReg(pLcdBase, HX8347_R50H, 0x46);
_HX8347_WriteReg(pLcdBase, HX8347_R51H, 0x46);
//240x320 window setting
_HX8347_WriteReg(pLcdBase, HX8347_R02H, 0x00); // Column address start2
_HX8347_WriteReg(pLcdBase, HX8347_R03H, 0x00); // Column address start1
_HX8347_WriteReg(pLcdBase, HX8347_R04H, 0x00); // Column address end2
_HX8347_WriteReg(pLcdBase, HX8347_R05H, 0xEF); // Column address end1
_HX8347_WriteReg(pLcdBase, HX8347_R06H, 0x00); // Row address start2
_HX8347_WriteReg(pLcdBase, HX8347_R07H, 0x00); // Row address start1
_HX8347_WriteReg(pLcdBase, HX8347_R08H, 0x01); // Row address end2
_HX8347_WriteReg(pLcdBase, HX8347_R09H, 0x3F); // Row address end1
// Display Setting
_HX8347_WriteReg(pLcdBase, HX8347_R01H, 0x06); // IDMON=0, INVON=1, NORON=1, PTLON=0
_HX8347_WriteReg(pLcdBase, HX8347_R16H, 0xC8); // MY=1, MX=1, MV=0, BGR=1
_HX8347_WriteReg(pLcdBase, HX8347_R23H, 0x95); // N_DC=1001 0101
_HX8347_WriteReg(pLcdBase, HX8347_R24H, 0x95); // P_DC=1001 0101
_HX8347_WriteReg(pLcdBase, HX8347_R25H, 0xFF); // I_DC=1111 1111
_HX8347_WriteReg(pLcdBase, HX8347_R27H, 0x06); // N_BP=0000 0110
_HX8347_WriteReg(pLcdBase, HX8347_R28H, 0x06); // N_FP=0000 0110
_HX8347_WriteReg(pLcdBase, HX8347_R29H, 0x06); // P_BP=0000 0110
_HX8347_WriteReg(pLcdBase, HX8347_R2AH, 0x06); // P_FP=0000 0110
_HX8347_WriteReg(pLcdBase, HX8347_R2CH, 0x06); // I_BP=0000 0110
_HX8347_WriteReg(pLcdBase, HX8347_R2DH, 0x06); // I_FP=0000 0110
_HX8347_WriteReg(pLcdBase, HX8347_R3AH, 0x01); // N_RTN=0000, N_NW=001
_HX8347_WriteReg(pLcdBase, HX8347_R3BH, 0x01); // P_RTN=0000, P_NW=001
_HX8347_WriteReg(pLcdBase, HX8347_R3CH, 0xF0); // I_RTN=1111, I_NW=000
_HX8347_WriteReg(pLcdBase, HX8347_R3DH, 0x00); // DIV=00
_HX8347_WriteReg(pLcdBase, HX8347_R3EH, 0x38); // SON=38h
_HX8347_WriteReg(pLcdBase, HX8347_R40H, 0x0F); // GDON=0Fh
_HX8347_WriteReg(pLcdBase, HX8347_R41H, 0xF0); // GDOF=F0h
}
//------------------------------------------------------------------------------
/// Turn on the LCD.
/// \param pLcdBase LCD base address.
//------------------------------------------------------------------------------
static void _HX8347_On( void *pLcdBase )
{
// Display ON Setting
_HX8347_WriteReg(pLcdBase, HX8347_R90H, 0x7F); // SAP=0111 1111
_HX8347_WriteReg(pLcdBase, HX8347_R26H, 0x04); // GON=0, DTE=0, D=01
Delay(100);
_HX8347_WriteReg(pLcdBase, HX8347_R26H, 0x24); // GON=1, DTE=0, D=01
_HX8347_WriteReg(pLcdBase, HX8347_R26H, 0x2C); // GON=1, DTE=0, D=11
Delay(100);
_HX8347_WriteReg(pLcdBase, HX8347_R26H, 0x3C); // GON=1, DTE=1, D=11
}
//------------------------------------------------------------------------------
/// Turn off the LCD.
/// \param pLcdBase LCD base address.
//------------------------------------------------------------------------------
static void _HX8347_Off( void *pLcdBase )
{
_HX8347_WriteReg(pLcdBase, HX8347_R90H, 0x00); // SAP=0000 0000
_HX8347_WriteReg(pLcdBase, HX8347_R26H, 0x00); // GON=0, DTE=0, D=00
}
//------------------------------------------------------------------------------
/// Set cursor of LCD srceen.
/// \param pLcdBase LCD base address.
/// \param x X-coordinate of upper-left corner on LCD.
/// \param y Y-coordinate of upper-left corner on LCD.
//------------------------------------------------------------------------------
static void _HX8347_SetCursor(void *pLcdBase, unsigned short x, unsigned short y)
{
unsigned char x1, x2, y1, y2;
x1 = x & 0xff;
x2 = (x & 0xff00) >>8;
y1 = y & 0xff;
y2 = (y & 0xff00) >>8;
_HX8347_WriteReg(pLcdBase, HX8347_R02H, x2); // column high
_HX8347_WriteReg(pLcdBase, HX8347_R03H, x1); // column low
_HX8347_WriteReg(pLcdBase, HX8347_R06H, y2); // row high
_HX8347_WriteReg(pLcdBase, HX8347_R07H, y1); // row low
}
//------------------------------------------------------------------------------
/// Set the window size user can access.
/// \param pLcdBase LCD base address.
/// \param x_start X-coordinate of upper-left corner on LCD.
/// \param y_start Y-coordinate of upper-left corner on LCD.
/// \param x_end X-coordinate of bottom-right corner on LCD.
/// \param y_end Y-coordinate of bottom-right corner on LCD.
//------------------------------------------------------------------------------
static void _HX8347_SetWindow(void *pLcdBase,unsigned short x_start, unsigned short y_start,unsigned short x_end, unsigned short y_end)
{
unsigned char x1, x2, y1, y2;
x1 = x_start & 0xff;
x2 = (x_start & 0xff00) >>8;
y1 = y_start & 0xff;
y2 = (y_start & 0xff00) >>8;
_HX8347_WriteReg(pLcdBase, 0x02, x2); // column high
_HX8347_WriteReg(pLcdBase, 0x03, x1); // column low
_HX8347_WriteReg(pLcdBase, 0x06, y2); // row high
_HX8347_WriteReg(pLcdBase, 0x07, y1); // row low
x1 = x_end & 0xff;
x2 = (x_end & 0xff00) >>8;
y1 = y_end & 0xff;
y2 = (y_end & 0xff00) >>8;
_HX8347_WriteReg(pLcdBase, 0x04, x2); // column high
_HX8347_WriteReg(pLcdBase, 0x05, x1); // column low
_HX8347_WriteReg(pLcdBase, 0x08, y2); // row high
_HX8347_WriteReg(pLcdBase, 0x09, y1); // row low
}
SDISPBackend sDISP_Backend_HX8347=
{
.sData={ 0 },
// .Reset=_DBE_HX8347_Reset,
// .Initialize=_DBE_HX8347_Initialize,
// .GetPixel=_DBE_HX8347_GetPixel,
// .SetPixel=_DBE_HX8347_SetPixel,
// .DrawLine=_DBE_HX8347_DrawLine,
// .DrawCircle=_DBE_HX8347_DrawCircle,
// .DrawFilledCircle=_DBE_HX8347_DrawFilledCircle,
// .DrawRectangle=_DBE_HX8347_DrawRectangle,
// .DrawFilledRectangle=_DBE_HX8347_DrawFilledRectangle,
// .DrawBitmap=_DBE_HX8347_DrawBitmap,
// .IOCtl=_DBE_HX8347_IOCtl
} ;
@@ -0,0 +1,90 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2008, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
//------------------------------------------------------------------------------
/// \unit
///
/// !!!Purpose
///
/// Definition of methods for HX8347 driver.
///
/// !!!Usage
///
/// -# LCD_WriteReg
/// -# LCD_ReadReg
/// -# LCD_ReadStatus
/// -# LCD_DumpReg
/// -# LCD_WriteRAM_Prepare
/// -# LCD_WriteRAM
/// -# LCD_ReadRAM_Prepare
/// -# LCD_ReadRAM
/// -# LCD_Initialize
/// -# LCD_SetCursor
/// -# LCD_On
/// -# LCD_Off
//------------------------------------------------------------------------------
#ifndef HX8347_H
#define HX8347_H
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include <board.h>
#include "disp/disp_backend.h"
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
/// Convert 24-bits color to 16-bits color
#define RGB24ToRGB16(color) (((color >> 8) & 0xF800) | \
((color >> 5) & 0x7E0) | \
((color >> 3) & 0x1F))
//------------------------------------------------------------------------------
// Global functions
//------------------------------------------------------------------------------
//void LCD_WriteReg(void *pLcdBase, unsigned char reg, unsigned short data);
//unsigned short LCD_ReadReg(void *pLcdBase, unsigned char reg);
//unsigned short LCD_ReadStatus(void *pLcdBase);
//void LCD_DumpReg(void *pLcdBase, unsigned char startAddr, unsigned char endAddr);
//void LCD_WriteRAM_Prepare(void *pLcdBase);
//void LCD_WriteRAM(void *pLcdBase, unsigned short color);
//void LCD_ReadRAM_Prepare(void *pLcdBase);
//unsigned short LCD_ReadRAM(void *pLcdBase);
//void LCD_Initialize(void *pLcdBase);
//void LCD_SetCursor(void *pLcdBase, unsigned short x, unsigned short y);
//void LCD_On(void *pLcdBase);
//void LCD_Off(void *pLcdBase);
//void LCD_SetWindow(void *pLcdBase,unsigned short x_start, unsigned short y_start,unsigned short x_end, unsigned short y_end);
extern SDISPBackend sDISP_Backend_HX8347 ;
#endif //#ifndef HX8347_H
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,52 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
/**
* \file
*
* Interface of ILI9325 driver.
*
*/
#ifndef _SAM_GUI_BACKEND_ILI9325_
#define _SAM_GUI_BACKEND_ILI9325_
/*----------------------------------------------------------------------------
* Headers
*----------------------------------------------------------------------------*/
#include "disp/disp_backend.h"
/*----------------------------------------------------------------------------
* Exported functions
*----------------------------------------------------------------------------*/
extern SDISPBackend sDISP_Backend_ILI9325 ;
#endif // _SAM_GUI_BACKEND_ILI9325_
@@ -0,0 +1,80 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
#include "disp/disp_backend.h"
#include "disp/backends/ILI9325/backend_ILI9325.h"
#include "disp/backends/HX8347/backend_HX8347.h"
#include "sam-gui/common/sam_gui_errors.h"
#include <stdlib.h>
#include <stdio.h>
//#define TRACE( x ) x
#define TRACE( x )
static __no_init SDISPBackend* _aDISP_Backends[DISP_BACKEND_MAX] ;
extern uint32_t DISP_Initialize( void )
{
_aDISP_Backends[DISP_BACKEND_HX8347]=NULL ; //&sDISP_Backend_HX8347 ;
_aDISP_Backends[DISP_BACKEND_ILI9325]=&sDISP_Backend_ILI9325 ;
for ( int i=0 ; i < DISP_BACKEND_MAX ; i++ )
{
TRACE( printf( "DISP_Initialize - [%d] %x\r\n", i, _aDISP_Backends[i] ) ; )
}
return SAMGUI_E_OK ;
}
extern uint32_t DISP_GetBackend( uint32_t dwIndex, SDISPBackend** ppBackend )
{
// Check pointers
if ( ppBackend == NULL )
{
return SAMGUI_E_BAD_POINTER ;
}
// Check parameters consistency
if ( dwIndex >= DISP_BACKEND_MAX )
{
return SAMGUI_E_BAD_PARAMETER ;
}
if ( _aDISP_Backends[dwIndex]->sData.dwID != dwIndex )
{
TRACE( printf( "DISP_GetBackend - Inconsistent backend %x\r\n", dwIndex ) ; )
return SAMGUI_E_WRONG_COMPONENT ;
}
*ppBackend=_aDISP_Backends[dwIndex] ;
TRACE( printf( "DISP_GetBackend - %x %x\r\n", _aDISP_Backends[dwIndex], *ppBackend ) ; )
return SAMGUI_E_OK ;
}
@@ -0,0 +1,78 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
#ifndef _SAM_GUI_DISP_BACKEND_
#define _SAM_GUI_DISP_BACKEND_
#include "sam-gui/common/sam_gui_color.h"
#include "sam-gui/common/sam_gui_font.h"
typedef struct _SDISPBackendData
{
uint32_t dwID ;
uint32_t dwOrientation ; // Portrait, Landscape
uint32_t dwMode ; // RGB, BGR
} sDISPBackendData ;
typedef struct _SDISPBackend
{
sDISPBackendData sData ;
uint32_t (*Reset)( void ) ;
uint32_t (*Initialize)( void ) ;
uint32_t (*GetPixel)( uint32_t dwX, uint32_t dwY, SGUIColor* pclrResult ) ;
uint32_t (*DrawPixel)( uint32_t dwX, uint32_t dwY, SGUIColor* pclrIn ) ;
uint32_t (*DrawLine)( uint32_t dwX1, uint32_t dwY1, uint32_t dwX2, uint32_t dwY2, SGUIColor* pclrIn ) ;
uint32_t (*DrawCircle)( uint32_t dwX, uint32_t dwY, uint32_t dwRadius, SGUIColor* pclrBorder ) ;
uint32_t (*DrawFilledCircle)( uint32_t dwX, uint32_t dwY, uint32_t dwRadius, SGUIColor* pclrBorder, SGUIColor* pclrInside ) ;
uint32_t (*DrawRectangle)( uint32_t dwX1, uint32_t dwY1, uint32_t dwX2, uint32_t dwY2, SGUIColor* pclrFrame ) ;
uint32_t (*DrawFilledRectangle)( uint32_t dwX1, uint32_t dwY1, uint32_t dwX2, uint32_t dwY2, SGUIColor* pclrFrame, SGUIColor* pclrInside ) ;
uint32_t (*DrawBitmap)( uint32_t dwX, uint32_t dwY, uint32_t dwWidth, uint32_t dwHeight, uint8_t* pucData ) ;
uint32_t (*DrawText)( uint32_t dwX, uint32_t dwY, uint8_t* pszText, SGUIColor* pclrText, SGUIFont* pFont, uint32_t dwSize ) ;
uint32_t (*Fill)( uint32_t dwX, uint32_t dwY, SGUIColor* pclrIn ) ;
uint32_t (*IOCtl)( uint32_t dwCommand, uint32_t* pdwValue, uint32_t* pdwValueLength ) ;
} SDISPBackend ;
#define DISP_BACKEND_IOCTL_POWER_ON 0x01L
#define DISP_BACKEND_IOCTL_POWER_OFF 0x02L
#define DISP_BACKEND_IOCTL_SET_BACKLIGHT 0x03L
#define DISP_BACKEND_IOCTL_SET_MODE_PORTRAIT 0x04L
#define DISP_BACKEND_IOCTL_SET_MODE_LANDSCAPE 0x05L
typedef enum _DISP_eBackend
{
DISP_BACKEND_HX8347,
DISP_BACKEND_ILI9325,
DISP_BACKEND_MAX
} DISP_eBackend ;
extern uint32_t DISP_Initialize( void ) ;
extern uint32_t DISP_GetBackend( uint32_t dwIndex, SDISPBackend** ppBackend ) ;
#endif // _SAM_GUI_DISP_BACKEND_
@@ -0,0 +1,29 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
@@ -0,0 +1,41 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
#ifndef _DISP_CORE_
#define _DISP_CORE_
#include "disp/disp_backend.h"
#include <stdio.h>
//#define TRACE( x ) x
#define TRACE( x )
#endif // _DISP_CORE_
+585
View File
@@ -0,0 +1,585 @@
ZSoft PCX File Format Technical Reference Manual
Introduction 2
Image File (.PCX) Format 3
ZSoft .PCX FILE HEADER FORMAT 4
Decoding .PCX Files 6
Palette Information Description 7
EGA/VGA 16 Color Palette Information 7
VGA 256 Color Palette Information 7
24-Bit .PCX Files 8
CGA Color Palette Information 8
CGA Color Map 8
PC Paintbrush Bitmap Character Format 9
Sample "C" Routines 10
FRIEZE Technical Information 14
General FRIEZE Information 14
7.00 and Later FRIEZE 14
FRIEZE Function Calls 15
FRIEZE Error Codes 18
Introduction
This booklet was designed to aid developers and users in understanding
the technical aspects of the .PCX file format and the use of FRIEZE.
Any comments, questions or suggestions about this booklet should be
sent to:
ZSoft Corporation
Technical Services
ATTN: Code Librarian
450 Franklin Rd. Suite 100
Marietta, GA 30067
Technical Reference Manual information compiled by:
Dean Ansley
Revision 5
To down load additional information and the source for a complete
Turbo Pascal program to show .PCX files on a CGA/EGA/VGA graphics
display, call our BBS at (404)427-1045. You may use a 9600 baud
modem or a 2400 baud standard modem. Your modem should be set for
8 data bits, 1 stop bit, and NO parity.
Image File (.PCX) Format
If you have technical questions on the format, please do not call
technical support. ZSoft provides this document as a courtesy to
its users and developers. It is not the function of Technical Support
to provide programming assistance. If something is not clear, leave a
message on our BBS, Compuserve, or write us a letter at the above address.
The information in this section will be useful if you want to write a
program to read or write PCX files (images). If you want to write a
special case program for one particular image format you should be able
to produce something that runs twice as fast as "Load from..." in
PC Paintbrush.
Image files used by PC Paintbrush product family and FRIEZE (those with a
.PCX extension) begin with a 128 byte header. Usually you can ignore this
header, since your images will probably all have the same resolution. If
you want to process different resolutions or colors, you will need to
interpret the header correctly. The remainder of the image file consists
of encoded graphic data. The encoding method is a simple byte oriented
run-length technique. We reserve the right to change this method to
improve space efficiency. When more than one color plane is stored in
the file, each line of the image is stored by color plane (generally ordered
red, green, blue, intensity), As shown below.
Scan line 0: RRR... (Plane 0)
GGG... (Plane 1)
BBB... (Plane 2)
III... (Plane 3)
Scan line 1: RRR...
GGG...
BBB...
III... (etc.)
The encoding method is:
FOR each byte, X, read from the file
IF the top two bits of X are 1's then
count = 6 lowest bits of X
data = next byte following X
ELSE
count = 1
data = X
Since the overhead this technique requires is, on average, 25% of
the non-repeating data and is at least offset whenever bytes are repeated,
the file storage savings are usually considerable.
ZSoft .PCX FILE HEADER FORMAT
Byte Item Size Description/Comments
0 Manufacturer 1 Constant Flag, 10 = ZSoft .pcx
1 Version 1 Version information
0 = Version 2.5 of PC Paintbrush
2 = Version 2.8 w/palette information
3 = Version 2.8 w/o palette information
4 = PC Paintbrush for Windows(Plus for
Windows uses Ver 5)
5 = Version 3.0 and > of PC Paintbrush
and PC Paintbrush +, includes
Publisher's Paintbrush . Includes
24-bit .PCX files
2 Encoding 1 1 = .PCX run length encoding
3 BitsPerPixel 1 Number of bits to represent a pixel
(per Plane) - 1, 2, 4, or 8
4 Window 8 Image Dimensions: Xmin,Ymin,Xmax,Ymax
12 HDpi 2 Horizontal Resolution of image in DPI*
14 VDpi 2 Vertical Resolution of image in DPI*
16 Colormap 48 Color palette setting, see text
64 Reserved 1 Should be set to 0.
65 NPlanes 1 Number of color planes
66 BytesPerLine 2 Number of bytes to allocate for a scanline
plane. MUST be an EVEN number. Do NOT
calculate from Xmax-Xmin.
68 PaletteInfo 2 How to interpret palette- 1 = Color/BW,
2 = Grayscale (ignored in PB IV/ IV +)
70 HscreenSize 2 Horizontal screen size in pixels. New field
found only in PB IV/IV Plus
72 VscreenSize 2 Vertical screen size in pixels. New field
found only in PB IV/IV Plus
74 Filler 54 Blank to fill out 128 byte header. Set all
bytes to 0
NOTES:
All sizes are measured in BYTES.
All variables of SIZE 2 are integers.
*HDpi and VDpi represent the Horizontal and Vertical resolutions which the
image was created (either printer or scanner); i.e. an image which was
scanned might have 300 and 300 in each of these fields.
Decoding .PCX Files
First, find the pixel dimensions of the image by calculating
[XSIZE = Xmax - Xmin + 1] and [YSIZE = Ymax - Ymin + 1]. Then calculate
how many bytes are required to hold one complete uncompressed scan line:
TotalBytes = NPlanes * BytesPerLine
Note that since there are always an even number of bytes per scan line,
there will probably be unused data at the end of each scan line. TotalBytes
shows how much storage must be available to decode each scan line, including
any blank area on the right side of the image. You can now begin decoding
the first scan line - read the first byte of data from the file. If the
top two bits are set, the remaining six bits in the byte show how many times
to duplicate the next byte in the file. If the top two bits are not set,
the first byte is the data itself, with a count of one.
Continue decoding the rest of the line. Keep a running subtotal of how
many bytes are moved and duplicated into the output buffer. When the
subtotal equals TotalBytes, the scan line is complete. There should always
be a decoding break at the end of each scan line. But there will not be a
decoding break at the end of each plane within each scan line. When the
scan line is completed, there may be extra blank data at the end of each
plane within the scan line. Use the XSIZE and YSIZE values to find where
the valid image data is. If the data is multi-plane, BytesPerLine shows
where each plane ends within the scan line.
Continue decoding the remainder of the scan lines (do not just read to
end-of-file). There may be additional data after the end of the image
(palette, etc.)
Palette Information Description
EGA/VGA 16 Color Palette Information
In standard RGB format (IBM EGA, IBM VGA) the data is stored as 16 triples.
Each triple is a 3 byte quantity of Red, Green, Blue values. The values can
range from 0-255, so some interpretation may be necessary. On an IBM EGA,
for example, there are 4 possible levels of RGB for each color. Since
256/4 = 64, the following is a list of the settings and levels:
Setting Level
0-63 0
64-127 1
128-192 2
193-254 3
VGA 256 Color Palette Information
ZSoft has recently added the capability to store palettes containing more
than 16 colors in the .PCX image file. The 256 color palette is formatted
and treated the same as the 16 color palette, except that it is substantially
longer. The palette (number of colors x 3 bytes in length) is appended to
the end of the .PCX file, and is preceded by a 12 decimal. Since the VGA
device expects a palette value to be 0-63 instead of 0-255, you need to
divide the values read in the palette by 4.
To access a 256 color palette:
First, check the version number in the header; if it contains a 5 there is
a palette.
Second, read to the end of the file and count back 769 bytes. The value
you find should be a 12 decimal, showing the presence of a 256 color palette.
24-Bit .PCX Files
24 bit images are stored as version 5 or above as 8 bit, 3 plane images.
24 bit images do not contain a palette.
Bit planes are ordered as lines of red, green, blue in that order.
CGA Color Palette Information
NOTE: This is no longer supported for PC Paintbrush IV/IV Plus.
For a standard IBM CGA board, the palette settings are a bit more complex.
Only the first byte of the triple is used. The first triple has a valid
first byte which represents the background color. To find the background,
take the (unsigned) byte value and divide by 16. This will give a result
between 0-15, hence the background color. The second triple has a valid
first byte, which represents the foreground palette. PC Paintbrush supports
8 possible CGA palettes, so when the foreground setting is encoded between
0 and 255, there are 8 ranges of numbers and the divisor is 32.
CGA Color Map
Header Byte #16
Background color is determined in the upper four bits.
Header Byte #19
Only upper 3 bits are used, lower 5 bits are ignored. The first three bits
that are used are ordered C, P, I. These bits are interpreted as follows:
c: color burst enable - 0 = color; 1 = monochrome
p: palette - 0 = yellow; 1 = white
i: intensity - 0 = dim; 1 = bright
PC Paintbrush Bitmap Character Format
NOTE: This format is for PC Paintbrush (up to Vers 3.7) and PC Paintbrush
Plus (up to Vers 1.65)
The bitmap character fonts are stored in a particularly simple format. The
format of these characters is as follows:
Header
font width byte 0xA0 + character width (in pixels)
font height byte character height (in pixels)
Character Width Table
char widths (256 bytes) each char's width + 1 pixel of kerning
Character Images
(remainder of the file) starts at char 0 (Null)
The characters are stored in ASCII order and as many as 256 may be provided.
Each character is left justified in the character block, all characters take
up the same number of bytes.
Bytes are organized as N strings, where each string is one scan line of the
character.
For example, each character in a 5x7 font requires 7 bytes. A 9x14 font
uses 28 bytes per character (stored two bytes per scan line in 14 sets of
2 byte packets). Custom fonts may be any size up to the current maximum of
10K bytes allowed for a font file. There is a maximum of 4 bytes per scan
line.
Sample "C" Routines
The following is a simple set of C subroutines to read data from a .PCX file.
/* This procedure reads one encoded block from the image file and stores a
count and data byte.
Return result: 0 = valid data stored, EOF = out of data in file */
encget(pbyt, pcnt, fid)
int *pbyt; /* where to place data */
int *pcnt; /* where to place count */
FILE *fid; /* image file handle */
{
int i;
*pcnt = 1; /* assume a "run" length of one */
if (EOF == (i = getc(fid)))
return (EOF);
if (0xC0 == (0xC0 & i))
{
*pcnt = 0x3F & i;
if (EOF == (i = getc(fid)))
return (EOF);
}
*pbyt = i;
return (0);
}
/* Here's a program fragment using encget. This reads an entire file and
stores it in a (large) buffer, pointed to by the variable "bufr". "fp" is
the file pointer for the image */
int i;
long l, lsize;
lsize = (long )hdr.BytesPerLine * hdr.Nplanes * (1 + hdr.Ymax - hdr.Ymin);
for (l = 0; l < lsize; ) /* increment by cnt below */
{
if (EOF == encget(&chr, &cnt, fp))
break;
for (i = 0; i < cnt; i++)
*bufr++ = chr;
l += cnt;
}
The following is a set of C subroutines to write data to a .PCX file.
/* Subroutine for writing an encoded byte pair (or single byte if it
doesn't encode) to a file. It returns the count of bytes written, 0 if error */
encput(byt, cnt, fid)
unsigned char byt, cnt;
FILE *fid;
{
if (cnt) {
if ((cnt == 1) && (0xC0 != (0xC0 & byt)))
{
if (EOF == putc((int )byt, fid))
return(0); /* disk write error (probably full) */
return(1);
}
else
{
if (EOF == putc((int )0xC0 | cnt, fid))
return (0); /* disk write error */
if (EOF == putc((int )byt, fid))
return (0); /* disk write error */
return (2);
}
}
return (0);
}
/* This subroutine encodes one scanline and writes it to a file.
It returns number of bytes written into outBuff, 0 if failed. */
encLine(inBuff, inLen, fp)
unsigned char *inBuff; /* pointer to scanline data */
int inLen; /* length of raw scanline in bytes */
FILE *fp; /* file to be written to */
{
unsigned char this, last;
int srcIndex, i;
register int total;
register unsigned char runCount; /* max single runlength is 63 */
total = 0;
runCount = 1;
last = *(inBuff);
/* Find the pixel dimensions of the image by calculating
[XSIZE = Xmax - Xmin + 1] and [YSIZE = Ymax - Ymin + 1].
Then calculate how many bytes are in a "run" */
for (srcIndex = 1; srcIndex < inLen; srcIndex++)
{
this = *(++inBuff);
if (this == last) /* There is a "run" in the data, encode it */
{
runCount++;
if (runCount == 63)
{
if (! (i = encput(last, runCount, fp)))
return (0);
total += i;
runCount = 0;
}
}
else /* No "run" - this != last */
{
if (runCount)
{
if (! (i = encput(last, runCount, fp)))
return(0);
total += i;
}
last = this;
runCount = 1;
}
} /* endloop */
if (runCount) /* finish up */
{
if (! (i = encput(last, runCount, fp)))
return (0);
return (total + i);
}
return (total);
}
FRIEZE Technical Information
General FRIEZE Information
FRIEZE is a memory-resident utility that allows you to capture and save
graphic images from other programs. You can then bring these images into
PC Paintbrush for editing and enhancement.
FRIEZE 7.10 and later can be removed from memory (this can return you up
to 90K of DOS RAM, depending on your configuration). To remove FRIEZE from
memory, change directories to your paintbrush directory and type the word
"FRIEZE".
7.00 and Later FRIEZE
The FRIEZE command line format is:
FRIEZE {PD} {Xn[aarr]} {flags} {video} {hres} {vres} {vnum}
Where:
{PD} Printer driver filename (without the .PDV extension)
{Xn[aarr]}
X=S for Serial Printer, P for Parallel Printer, D for disk file.
(file is always named FRIEZE.PRN)
n = port number
aa = Two digit hex code for which return bits cause
an abort (optional)
rr = Two digit hex code for which return bits cause
a retry (optional)
NOTE: These codes represent return values from serial or
parallel port BIOS calls. For values see and IBM
BIOS reference (such as Ray Duncan's Advanced MS-DOS
Programming).
{flags}Four digit hex code
First Digit controls Length Flag
Second Digit controls Width Flag
Third Digit controls Mode Flag
Fourth Digit controls BIOS Flag
0 - None
1 - Dual Monitor Present
2 - Use internal (true) B/W palette for dithering
2 color images
4 - Capture palette along with screen IN VGA ONLY
Frieze 8.08 & up ONLY)
NOTE: The length, width and mode flags are printer driver specific.
See PRINTERS.DAT on disk 1 (or Setup Disk) for correct use. In general
width flag of 1 means wide carriage, and 0 means standard width. Length
flag of 0 and mode flag of 0 means use default printer driver settings.
If you need to use more than one BIOS flag option, add the needed flag values
and use the sum as the flag value.
{video} Video driver combination, where the leading digit signifies the
high level video driver and the rest signifies the low
level video driver
Example = 1EGA - uses DRIVE1 and EGA.DEV
{hres} Horizontal resolution of the desired graphics mode
{vres} Vertical resolution of the desired graphics mode
{vnum} Hardware specific parameter (usually number of color planes)
Note: The last four parameters can be obtained from the CARDS.DAT file,
in your PC Paintbrush product directory.
FRIEZE Function Calls
FRIEZE is operated using software interrupt number 10h (the video interrupt
call).
To make a FRIEZE function call, load 75 (decimal) into the AH register and
the function number into the CL register, then either load AL with the
function argument or load ES and BX with a segment and offset which point
to the function argument. Do an int 10h. FRIEZE will return a result code
number in AX. All other registers are preserved. In general, a result
code of 0 means success and other values indicate errors. However, function
20 (get Frieze Version) behaves differently; see below.
No. Definition Arguments
0 Reserved
1 Load Window
ES:BX - string (filename to read from)
2 Save Window
ES:BX - string (filename to write to)
3 Reserved
4 Reserved
6 Reserved
7 Set Window Size
ES:BX - 4 element word vector of window settings:
Xmin, Ymin, Xmax, Ymax
8 Reserved
9 Set Patterns
ES:BX - 16 element vector of byte values
containing the screen-to-printer color correspondence
10 Get Patterns
ES:BX - room for 16 bytes as above
11 Set Mode
12,13,14 Reserved
15 Get Window
ES:BX - room for 4 words of the current window
settings
16 Set Print Options
ES:BX - character string of printer options.
Same format as for the FRIEZE command.
17, 18, 19 Reserved
20 Get FRIEZE Version.
AH gets the whole number portion and AL gets the
decimal portion of the version number. (eg. for
Freize vesion 7.41, AH will contain 7 and AL will
contain 41. If AH =0, you are calling a pre-7.0
version of FRIEZE).
21 Set Parameters
ES:BX points to an 8 word table (16 bytes) of
parameter settings: TopMargin, LeftMargin,
HSize,VSize, Quality/Draft Mode, PrintHres,
PrintVres, Reserved.
Margins and sizes are specified in hundredths
of inches.
Q/D mode parameter values:
0 - draft print mode
1 - quality print mode
Print resolutions are specified in DPI.
Any parameter which should be left unchanged may
be filled with a (-1) (0FFFF hex). The reserved
settings should be filled with a (-1).
22 Get Parameters
ES:BX points to an 8 word table (16 bytes) where
parameter settings are held.
23 Get Printer Res
ES:BX points to a 12 word table (24 bytes) that
holds six printer resolution pairs.
24 Reserved (versions 8.00 & up)
FRIEZE Error Codes
When FRIEZE is called using interrupt 10 hex, it will return an error code
in the AX register. A value of zero shows that there was no error. A
nonzero result means there was an error. These error codes are explained
below.
0 No Error
1 Printout was stopped by user with the ESC key
2 Reserved
3 File read error
4 File write error
5 File not found
6 Invalid Header - not an image, wrong screen mode
7 File close error
8 Disk error - usually drive door open
9 Printer error - printer is off or out of paper
10 Invalid command - CL was set to call a nonexistent FRIEZE function
11 Can't create file - write protect tab or disk is full
12 Wrong video mode - FRIEZE cannot capture text screens.
Technical Reference Manual
Including information for:
Publisher's Paintbrushr
PC Paintbrush IVTM
PC Paintbrush IV PlusTM
PC Paintbrush PlusTM
PC Paintbrushr
FRIEZETM Graphics
PaintbrushTM
Revision 5
ZSoft Corporation
450 Franklin Rd. Suite 100
Marietta, GA 30067
(404) 428-0008
(404) 427-1150 Fax
(404) 427-1045 BBS
Copyright c 1985, 1987, 1988, 1990, 1991, ZSoft Corporation
All Rights Reserved
@@ -0,0 +1,13 @@
#ifndef _FILE_FS_
#define _FILE_FS_
#include "fat/fatfs/src/ff.h"
#if _FS_TINY == 0
# define STR_ROOT_DIRECTORY "0:"
#else
# define STR_ROOT_DIRECTORY ""
#endif
#endif // _FILE_FS_
@@ -0,0 +1,23 @@
#include "sam_gui_porting.h"
#if SAM_PORTING == SAM_PORTING_FREERTOS
extern void SAMGUI_TaskDelay( uint32_t dwDelayMs )
{
vTaskDelay( dwDelayMs/portTICK_RATE_MS ) ;
}
extern int SAMGUI_TaskCreate( SAMGUI_fnTask fnTask, const uint8_t* pucName, uint8_t* pucStack, uint32_t dwStackSize,
uint32_t dwPriority, void* pvParameters, SAMGUI_TaskHandle* pHandle )
{
xTaskCreate( fnTask, (signed char const*)pucName, dwStackSize, pvParameters, tskIDLE_PRIORITY, pHandle ) ;
return (pHandle != NULL) ;
}
extern void SAMGUI_TaskDelete( SAMGUI_TaskHandle Handle )
{
vTaskDelete( Handle ) ;
}
#endif // SAM_PORTING == SAM_PORTING_FREERTOS
@@ -0,0 +1,37 @@
#ifndef _SAM_GUI_PORTING_
#define _SAM_GUI_PORTING_
#include <stdint.h>
#define SAM_PORTING_FREERTOS 1
#define SAM_PORTING_EMBOS 2
#define SAM_PORTING_NUTTX 3
//#define SAM_PORTING SAM_PORTING_FREERTOS
#if !defined SAM_PORTING
#error SAM_PORTING must be defined
#endif
/*
* Definitions for FreeRTOs
*/
#if SAM_PORTING == SAM_PORTING_FREERTOS
// FreeRTOS includes
# include "FreeRTOS.h"
# include "task.h"
# define SAMGUI_TaskHandle xTaskHandle
#endif // SAM_PORTING == SAM_PORTING_FREERTOS
typedef void (*SAMGUI_fnTask)( void* pvParam ) ;
extern void SAMGUI_TaskDelay( uint32_t dwDelayMs ) ;
extern int SAMGUI_TaskCreate( SAMGUI_fnTask fnTask, const uint8_t* pucName, uint8_t* pucStack, uint32_t dwStackSize,
uint32_t dwPriority, void* pvParameters, SAMGUI_TaskHandle* pHandle ) ;
void SAMGUI_TaskDelete( SAMGUI_TaskHandle Handle ) ;
#endif // _SAM_GUI_PORTING_
@@ -0,0 +1,198 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
#include "sam-gui/wgt/core/wgt_core.h"
#include "sam-gui/common/sam_gui_errors.h"
#include "sam-gui/porting/sam_gui_porting.h"
#include "disp/disp_backend.h"
#include "sam-gui/common/sam_gui_font.h"
#include "tsd/tsd_ads7843.h"
#include "sam-gui/common/sam_gui_colors.h"
#include "sam-gui/wgt/core/wgt_core_behaviour.h"
#include <string.h>
#include <stdio.h>
#include "board.h"
#include "lcd/color.h"
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#define WGT_CORE_MSG_QUEUE_SIZE 32
SWGTCoreData g_WGT_CoreData ;
// ------------------------------------------------------------------------------------------------
/** \brief
*/
static void _WGT_TaskMessageLoop( void* pParameter )
{
SWGTCoreData* pData=(SWGTCoreData*)pParameter ;
SWGTCoreMessage xMessage ;
WGT_Start() ;
for ( ; ; )
{
// Wait for a widget message
// if ( xQueueReceive( pData->hMessagesQueue, &xMessage, portMAX_DELAY ) == pdPASS )
if ( xQueueReceive( pData->hMessagesQueue, &xMessage, g_WGT_CoreData.dwTimerDelay/portTICK_RATE_MS ) == pdTRUE )
{
if ( g_WGT_CoreData.pCurrentScreen != NULL )
{
PreProcessMessage_Default( g_WGT_CoreData.pCurrentScreen, &xMessage ) ;
}
}
else // delay, send timer
{
if ( g_WGT_CoreData.pCurrentScreen != NULL )
{
xMessage.dwID=WGT_MSG_TIMER ;
if ( g_WGT_CoreData.pCurrentScreen->ProcessMessage( g_WGT_CoreData.pCurrentScreen, &xMessage ) == SAMGUI_E_OK )
{
}
}
}
}
}
// ------------------------------------------------------------------------------------------------
/** \brief
*/
extern uint32_t WGT_Initialize( void )
{
uint32_t dwError ;
// Set Timer Delay to 1s
g_WGT_CoreData.dwTimerDelay=1000 ;
// Create the queue used by the Messages task.
g_WGT_CoreData.hMessagesQueue=xQueueCreate( WGT_CORE_MSG_QUEUE_SIZE, sizeof( SWGTCoreMessage ) ) ;
// Create the Messages task.
xTaskCreate( _WGT_TaskMessageLoop, "WGT_ML", 512, &g_WGT_CoreData, tskIDLE_PRIORITY+1, NULL ) ;
// Initialize LCD backend.
dwError=DISP_GetBackend( DISP_BACKEND_ILI9325, &g_WGT_CoreData.pBE ) ;
if ( dwError != SAMGUI_E_OK )
{
printf( "_TaskLCD - Error getting Backend (%x)\r\n", dwError ) ;
return dwError ;
}
// Initialize frontends.
WGT_Frontend_Initialize() ;
return SAMGUI_E_OK ;
}
/** \brief
*/
extern uint32_t WGT_Start( void )
{
SGUIColor clrWhite={ .u.dwRGBA=COLOR_WHITE } ;
// Initialize backend.
g_WGT_CoreData.pBE->IOCtl( DISP_BACKEND_IOCTL_POWER_OFF, NULL, NULL ) ;
g_WGT_CoreData.pBE->Initialize() ;
// g_WGT_CoreData.pBE->IOCtl( DISP_BACKEND_IOCTL_SET_BACKLIGHT, (uint32_t*)1, NULL ) ;
g_WGT_CoreData.pBE->DrawFilledRectangle( 0, 0, BOARD_LCD_WIDTH, BOARD_LCD_HEIGHT, NULL, &clrWhite ) ;
g_WGT_CoreData.pBE->IOCtl( DISP_BACKEND_IOCTL_POWER_ON, NULL, NULL ) ;
// Initialize frontends.
if ( WGT_Frontend_GetFrontend( WGT_FRONTEND_ADS7843, &g_WGT_CoreData.pTSD ) == SAMGUI_E_OK )
{
g_WGT_CoreData.pTSD->Initialize() ;
}
if ( WGT_Frontend_GetFrontend( WGT_FRONTEND_PUSHBUTTONS, &g_WGT_CoreData.pPushbuttons ) == SAMGUI_E_OK )
{
g_WGT_CoreData.pPushbuttons->Initialize() ;
}
if ( WGT_Frontend_GetFrontend( WGT_FRONTEND_POTENTIOMETER, &g_WGT_CoreData.pPotentiometer ) == SAMGUI_E_OK )
{
g_WGT_CoreData.pPotentiometer->Initialize() ;
}
if ( WGT_Frontend_GetFrontend( WGT_FRONTEND_QTOUCH, &g_WGT_CoreData.pQTouch ) == SAMGUI_E_OK )
{
g_WGT_CoreData.pQTouch->Initialize() ;
}
return SAMGUI_E_OK ;
}
/** \brief
*/
extern uint32_t WGT_SetTimerPeriod( uint32_t dwDelay )
{
uint32_t dw ;
dw=g_WGT_CoreData.dwTimerDelay ;
g_WGT_CoreData.dwTimerDelay=dwDelay ;
return dw ;
}
/** \brief
*/
extern uint32_t WGT_GetTimerPeriod( void )
{
return g_WGT_CoreData.dwTimerDelay ;
}
/** \brief
*/
extern uint32_t WGT_SetCurrentScreen( SWGTScreen* pScreen )
{
if ( pScreen == NULL )
{
return SAMGUI_E_BAD_POINTER ;
}
g_WGT_CoreData.pCurrentScreen=pScreen ;
WGT_PostMessage( WGT_MSG_INIT, 0, 0 ) ;
WGT_PostMessage( WGT_MSG_ERASE_BKGND, 0, 0 ) ;
WGT_PostMessage( WGT_MSG_PAINT, 0, 0 ) ;
return SAMGUI_E_OK ;
}
@@ -0,0 +1,72 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
#ifndef _SAMGUI_WIDGET_CORE_
#define _SAMGUI_WIDGET_CORE_
//#include "common/sam_gui_color.h"
#include "common/sam_gui_font.h"
//#include "common/sam_gui_point.h"
//#include "common/sam_gui_size.h"
#include "disp/disp_backend.h"
//#include "sam-gui/wgt/core/wgt_core_widget.h"
#include "sam-gui/wgt/core/wgt_core_screen.h"
#include "sam-gui/wgt/core/wgt_core_frontend.h"
#include "FreeRTOS.h"
#include "queue.h"
typedef struct _SWGTCoreData
{
xQueueHandle hMessagesQueue ;
SDISPBackend* pBE ;
SWGTFrontend* pTSD ;
SWGTFrontend* pQTouch ;
SWGTFrontend* pPotentiometer ;
SWGTFrontend* pPushbuttons ;
SWGTScreen* pCurrentScreen ;
uint32_t dwTimerDelay ;
} SWGTCoreData ;
extern SWGTCoreData g_WGT_CoreData ;
// ------------------------------------------------------------------------------------------------
extern uint32_t WGT_Initialize( void ) ;
extern uint32_t WGT_Start( void ) ;
extern uint32_t WGT_SetTimerPeriod( uint32_t dwDelay ) ;
extern uint32_t WGT_GetTimerPeriod( void ) ;
extern uint32_t WGT_SetCurrentScreen( SWGTScreen* pScreen ) ;
#endif // _SAMGUI_WIDGET_CORE_
@@ -0,0 +1,29 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
@@ -0,0 +1,35 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
#ifndef _SAMGUI_WIDGET_CORE_BEHAVIOUR_
#define _SAMGUI_WIDGET_CORE_BEHAVIOUR_
extern uint32_t PreProcessMessage_Default( struct _SWGTScreen* pScreen, SWGTCoreMessage* pMsg ) ;
#endif // _SAMGUI_WIDGET_CORE_BEHAVIOUR_
@@ -0,0 +1,130 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
#include "sam-gui/wgt/core/wgt_core.h"
#include "sam-gui/common/sam_gui_errors.h"
#include "sam-gui/common/sam_gui_colors.h"
#include <stdio.h>
#include "FreeRTOS.h"
#include "task.h"
extern uint32_t PreProcessMessage_Default( struct _SWGTScreen* pScreen, SWGTCoreMessage* pMsg )
{
SWGT_Widget* pWidget ;
SGUIColor clrBlack={ .u.dwRGBA=GUICLR_BLACK } ;
static uint32_t dwPointerTimeStampOld=0 ;
static uint32_t dwPointerTimeStamp=0 ;
// Intercept special message for code factorization
switch ( pMsg->dwID )
{
case WGT_MSG_POINTER :
// Draw point
// g_WGT_CoreData.pBE->DrawPixel( pMsg->dwParam1, pMsg->dwParam2, &clrBlack ) ;
if ( WGT_Screen_GetPointedWidget( g_WGT_CoreData.pCurrentScreen, pMsg->dwParam1, pMsg->dwParam2, &pWidget ) == SAMGUI_E_OK )
{
if ( WGT_Screen_SetSelectedWidget( g_WGT_CoreData.pCurrentScreen, pWidget ) == SAMGUI_E_OK )
{
}
}
break ;
case WGT_MSG_POINTER_RELEASED :
#if 0
dwPointerTimeStampOld=dwPointerTimeStamp ;
dwPointerTimeStamp=xTaskGetTickCount() ;
printf( "PreProcessMessage_Default - double tap %u %u\r\n", dwPointerTimeStampOld, dwPointerTimeStamp ) ;
// Check double tap
if ( ((dwPointerTimeStamp-dwPointerTimeStampOld) > 300) &&
((dwPointerTimeStamp-dwPointerTimeStampOld) < 1000) )
{
if ( WGT_Screen_GetSelectedWidget( pScreen, &pWidget ) == SAMGUI_E_OK )
{
WGT_PostMessage( WGT_MSG_WIDGET_SELECTED, (uint32_t)pWidget, 0 ) ;
}
}
#else
if ( WGT_Screen_GetPointedWidget( g_WGT_CoreData.pCurrentScreen, pMsg->dwParam1, pMsg->dwParam2, &pWidget ) == SAMGUI_E_OK )
{
if ( WGT_Screen_SetSelectedWidget( g_WGT_CoreData.pCurrentScreen, pWidget ) == SAMGUI_E_OK )
{
WGT_PostMessage( WGT_MSG_WIDGET_SELECTED, (uint32_t)pWidget, 0 ) ;
}
}
#endif
// pointer has been released, repaint last selected widget
// if ( pScreen->pWidgetCurrent != NULL )
// {
// WGT_Draw( pScreen->pWidgetCurrent, g_WGT_CoreData.pBE ) ;
// pScreen->pWidgetOld=pScreen->pWidgetCurrent=NULL ;
// }
break ;
case WGT_MSG_INIT :
// Reset selected widget
pScreen->pWidgetOld=pScreen->pWidgetCurrent=NULL ;
if ( g_WGT_CoreData.pCurrentScreen->OnInitialize )
{
g_WGT_CoreData.pCurrentScreen->OnInitialize( g_WGT_CoreData.pCurrentScreen ) ;
}
break ;
case WGT_MSG_ERASE_BKGND :
WGT_Screen_OnEraseBackground( g_WGT_CoreData.pCurrentScreen ) ;
if ( g_WGT_CoreData.pCurrentScreen->OnEraseBackground )
{
g_WGT_CoreData.pCurrentScreen->OnEraseBackground( g_WGT_CoreData.pCurrentScreen ) ;
}
break ;
case WGT_MSG_PAINT :
WGT_Screen_OnPaint( g_WGT_CoreData.pCurrentScreen ) ;
if ( g_WGT_CoreData.pCurrentScreen->OnPaint )
{
g_WGT_CoreData.pCurrentScreen->OnPaint( g_WGT_CoreData.pCurrentScreen ) ;
}
break ;
}
// Send message to screen main callbacks
if ( g_WGT_CoreData.pCurrentScreen->ProcessMessage != NULL )
{
if ( g_WGT_CoreData.pCurrentScreen->ProcessMessage( g_WGT_CoreData.pCurrentScreen, pMsg ) == SAMGUI_E_OK )
{
}
}
return SAMGUI_E_OK ;
}
@@ -0,0 +1,84 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
#include "sam-gui/wgt/core/wgt_core_frontend.h"
#include "sam-gui/common/sam_gui_errors.h"
#include "sam-gui/wgt/frontends/frontend_ADS7843.h"
#include "sam-gui/wgt/frontends/frontend_pushbuttons.h"
#include "sam-gui/wgt/frontends/frontend_potentiometer.h"
#include "sam-gui/wgt/frontends/frontend_qtouch.h"
#include <stdlib.h>
#include <stdio.h>
#define TRACE( x ) x
//#define TRACE( x )
static __no_init SWGTFrontend* _aWGT_Frontends[WGT_FRONTEND_MAX] ;
extern uint32_t WGT_Frontend_Initialize( void )
{
_aWGT_Frontends[WGT_FRONTEND_ADS7843]=(void*)&sWGT_Frontend_ADS7843 ;
_aWGT_Frontends[WGT_FRONTEND_PUSHBUTTONS]=(void*)&sWGT_Frontend_PushButtons ;
_aWGT_Frontends[WGT_FRONTEND_POTENTIOMETER]=(void*)&sWGT_Frontend_Potentiometer ;
_aWGT_Frontends[WGT_FRONTEND_QTOUCH]=(void*)&sWGT_Frontend_QTouch ;
// for ( int i=0 ; i < WGT_FRONTEND_MAX ; i++ )
// {
// TRACE( printf( "WGT_Frontend_Initialize - [%d] %x\r\n", i, _aWGT_Frontends[i] ) ; )
// }
return SAMGUI_E_OK ;
}
extern uint32_t WGT_Frontend_GetFrontend( uint32_t dwIndex, SWGTFrontend** ppFrontend )
{
// Check pointers
if ( ppFrontend == NULL )
{
return SAMGUI_E_BAD_POINTER ;
}
// Check parameters consistency
if ( dwIndex >= WGT_FRONTEND_MAX )
{
return SAMGUI_E_BAD_PARAMETER ;
}
if ( _aWGT_Frontends[dwIndex]->sData.dwId != dwIndex )
{
TRACE( printf( "WGT_Frontend_GetFrontend - Inconsistent frontend %x/%x\r\n", dwIndex, _aWGT_Frontends[dwIndex]->sData.dwId ) ; )
return SAMGUI_E_WRONG_COMPONENT ;
}
*ppFrontend=_aWGT_Frontends[dwIndex] ;
// TRACE( printf( "WGT_Frontend_GetFrontend - %x %x\r\n", _aWGT_Frontends[dwIndex], *ppFrontend ) ; )
return SAMGUI_E_OK ;
}
@@ -0,0 +1,61 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
#ifndef _SAM_GUI_WGT_FRONTEND_
#define _SAM_GUI_WGT_FRONTEND_
typedef struct _SWGTFrontendData
{
uint32_t dwId ;
} sWGTFrontendData ;
typedef struct _SWGTFrontend
{
sWGTFrontendData sData ;
uint32_t (*Initialize)( void ) ;
uint32_t (*IOCtl)( uint32_t dwCommand, uint32_t* pdwValue, uint32_t* pdwValueLength ) ;
} SWGTFrontend ;
#define WGT_FRONTEND_IOCTL_SET_DATA 0x01L
typedef enum _WGT_eFrontend
{
WGT_FRONTEND_ADS7843,
WGT_FRONTEND_PUSHBUTTONS,
WGT_FRONTEND_POTENTIOMETER,
WGT_FRONTEND_QTOUCH,
WGT_FRONTEND_MAX
} WGT_eFrontend ;
extern uint32_t WGT_Frontend_Initialize( void ) ;
extern uint32_t WGT_Frontend_GetFrontend( uint32_t dwIndex, SWGTFrontend** ppFrontend ) ;
#endif // _SAM_GUI_WGT_FRONTEND_
@@ -0,0 +1,112 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
#include "sam-gui/wgt/core/wgt_core_message.h"
#include "sam-gui/wgt/core/wgt_core.h"
#include "sam-gui/common/sam_gui_errors.h"
#include <string.h>
/** \brief
*/
extern uint32_t WGT_SendMessage( uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 )
{
SWGTCoreMessage sMsg ;
sMsg.dwID=dwMsgID ;
sMsg.dwParam1=dwParam1 ;
sMsg.dwParam2=dwParam2 ;
// Send message
if ( xQueueSendToFront( g_WGT_CoreData.hMessagesQueue, &sMsg, ( portTickType )10 ) != pdPASS )
{
return SAMGUI_E_MSQUEUE ;
}
return SAMGUI_E_OK ;
}
/** \brief
*/
extern uint32_t WGT_PostMessage( uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 )
{
SWGTCoreMessage sMsg ;
sMsg.dwID=dwMsgID ;
sMsg.dwParam1=dwParam1 ;
sMsg.dwParam2=dwParam2 ;
// Post message
if ( xQueueSendToBack( g_WGT_CoreData.hMessagesQueue, &sMsg, ( portTickType )0 ) != pdPASS )
{
return SAMGUI_E_MSQUEUE ;
}
return SAMGUI_E_OK ;
}
/** \brief
*/
extern uint32_t WGT_SendMessageISR( uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 )
{
SWGTCoreMessage sMsg ;
sMsg.dwID=dwMsgID ;
sMsg.dwParam1=dwParam1 ;
sMsg.dwParam2=dwParam2 ;
// Send message
if ( xQueueSendToFrontFromISR( g_WGT_CoreData.hMessagesQueue, &sMsg, NULL ) != pdPASS )
{
return SAMGUI_E_MSQUEUE ;
}
return SAMGUI_E_OK ;
}
/** \brief
*/
extern uint32_t WGT_PostMessageISR( uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 )
{
SWGTCoreMessage sMsg ;
sMsg.dwID=dwMsgID ;
sMsg.dwParam1=dwParam1 ;
sMsg.dwParam2=dwParam2 ;
// Post message
if ( xQueueSendToBackFromISR( g_WGT_CoreData.hMessagesQueue, &sMsg, NULL ) != pdPASS )
{
return SAMGUI_E_MSQUEUE ;
}
return SAMGUI_E_OK ;
}
// signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void * const pvItemToQueue, signed portBASE_TYPE *pxHigherPriorityTaskWoken, portBASE_TYPE xCopyPosition )
// signed portBASE_TYPE xQueueGenericSend ( xQueueHandle xQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition );
@@ -0,0 +1,80 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
#ifndef _SAMGUI_WIDGET_CORE_MESSAGE_
#define _SAMGUI_WIDGET_CORE_MESSAGE_
typedef enum _WGT_Message
{
WGT_MSG_INIT, // 0
WGT_MSG_ERASE_BKGND, // 1
WGT_MSG_PAINT, // 2
WGT_MSG_TIMER, // 3
WGT_MSG_POINTER_RAW, // 4
WGT_MSG_POINTER, // 5
WGT_MSG_POINTER_PRESSED, // 6
WGT_MSG_POINTER_RELEASED, // 7
WGT_MSG_WIDGET_SELECTED, // 8
WGT_MSG_KEY_PRESSED, // 9
WGT_MSG_KEY_RELEASED, // 10
WGT_MSG_USER1, // 11
WGT_MSG_USER2,
WGT_MSG_USER3,
WGT_MSG_USER4,
WGT_MSG_USER5,
WGT_MSG_MAX
} WGT_Message ;
typedef enum _SWGT_KeyCode
{
WGT_KEY_NRST,
WGT_KEY_PB1,
WGT_KEY_PB2,
WGT_KEY_K1,
WGT_KEY_K2,
WGT_KEY_K3,
WGT_KEY_K4,
WGT_KEY_K5,
WGT_KEY_S1,
WGT_KEY_VR1
} SWGT_KeyCode ;
typedef struct _SWGTCoreMessage
{
uint32_t dwID ;
uint32_t dwParam1 ;
uint32_t dwParam2 ;
} SWGTCoreMessage ;
extern uint32_t WGT_SendMessage( uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 ) ;
extern uint32_t WGT_PostMessage( uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 ) ;
extern uint32_t WGT_SendMessageISR( uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 ) ;
extern uint32_t WGT_PostMessageISR( uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 ) ;
#endif // _SAMGUI_WIDGET_CORE_MESSAGE_
@@ -0,0 +1,54 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
#include "sam-gui/wgt/core/wgt_core_pointer.h"
#include "sam-gui/common/sam_gui_errors.h"
static uint32_t _WGT_Pointer_dwStatus=0 ;
extern void WGT_Pointer_Disable( void )
{
_WGT_Pointer_dwStatus=0 ;
}
extern void WGT_Pointer_Enable( void )
{
_WGT_Pointer_dwStatus=1 ;
}
extern uint32_t WGT_Pointer_SetBitmap( void )
{
return SAMGUI_E_OK ;
}
extern uint32_t WGT_Pointer_Draw( void )
{
return SAMGUI_E_OK ;
}
@@ -0,0 +1,40 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
#ifndef _WGT_CORE_POINTER_
#define _WGT_CORE_POINTER_
extern void WGT_Pointer_Disable( void ) ;
extern void WGT_Pointer_Enable( void ) ;
extern uint32_t WGT_Pointer_SetBitmap( void ) ;
extern uint32_t WGT_Pointer_Draw( void ) ;
#endif // _WGT_CORE_POINTER_
@@ -0,0 +1,307 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
#include "sam-gui/wgt/core/wgt_core_screen.h"
#include "sam-gui/common/sam_gui_errors.h"
#include "common/sam_gui_color.h"
#include "sam-gui/wgt/core/wgt_core.h"
#include "sam-gui/common/sam_gui_colors.h"
#include "board.h"
#include <string.h>
#include <stdio.h>
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
// ------------------------------------------------------------------------------------------------
// Screen functions
// ------------------------------------------------------------------------------------------------
extern uint32_t WGT_Screen_Initialize( SWGTScreen* pScreen, uint32_t dwClrBackground, uint8_t* pucBmpBackground )
{
memset( pScreen->apWidgets, 0, sizeof( pScreen->apWidgets ) ) ;
pScreen->dwWidgets=0 ;
pScreen->pWidgetOld=NULL ;
pScreen->pWidgetCurrent=NULL ;
pScreen->dwClrBackground=dwClrBackground ;
pScreen->pucBmpBackground=pucBmpBackground ;
return SAMGUI_E_OK ;
}
extern uint32_t WGT_Screen_AddWidget( SWGTScreen* pScreen, SWGT_Widget* pWidget )
{
if ( pScreen->dwWidgets == WGT_MAX_WIDGETS )
{
printf( "WGT_Screen_AddWidget - too much\r\n" ) ;
return SAMGUI_E_TOO_MUCH_WIDGETS ;
}
pScreen->apWidgets[pScreen->dwWidgets]=pWidget ;
pWidget->dwID=pScreen->dwWidgets ;
pScreen->dwWidgets++ ;
return SAMGUI_E_OK ;
}
extern uint32_t WGT_Screen_GetPointedWidget( SWGTScreen* pScreen, uint32_t dwX, uint32_t dwY, SWGT_Widget** ppWidget )
{
uint32_t dw ;
if ( pScreen == NULL )
{
return SAMGUI_E_BAD_POINTER ;
}
for ( dw=0 ; dw < pScreen->dwWidgets ; dw++ )
{
if ( pScreen->apWidgets[dw] )
{
// Check bounding box
if ( (dwX >= pScreen->apWidgets[dw]->dwX) && (dwX < pScreen->apWidgets[dw]->dwX+pScreen->apWidgets[dw]->dwWidth) &&
(dwY >= pScreen->apWidgets[dw]->dwY) && (dwY < pScreen->apWidgets[dw]->dwY+pScreen->apWidgets[dw]->dwHeight) )
{
if ( pScreen->apWidgets[dw]->dwType == WGT_TYPE_BUTTON )
{
if ( ppWidget != NULL )
{
*ppWidget=pScreen->apWidgets[dw] ;
}
return SAMGUI_E_OK ;
}
}
}
}
return SAMGUI_E_NO_SELECTED_WIDGET ;
}
extern uint32_t WGT_Screen_GetSelectedWidget( SWGTScreen* pScreen, SWGT_Widget** ppWidget )
{
if ( pScreen == NULL )
{
return SAMGUI_E_BAD_PARAMETER ;
}
if ( ppWidget != NULL )
{
*ppWidget=pScreen->pWidgetCurrent ;
return SAMGUI_E_OK ;
}
return SAMGUI_E_BAD_POINTER ;
}
extern uint32_t WGT_Screen_SetSelectedWidget( SWGTScreen* pScreen, SWGT_Widget* pWidget )
{
uint32_t dw ;
SGUIColor clrSelection={ .u.dwRGBA=GUICLR_ATMEL_BLUE } ;
if ( pScreen == NULL )
{
return SAMGUI_E_BAD_PARAMETER ;
}
for ( dw=0 ; dw < pScreen->dwWidgets ; dw++ )
{
if ( pScreen->apWidgets[dw] == pWidget )
{
pScreen->pWidgetCurrent=pWidget ;
if ( pScreen->pWidgetOld != pScreen->pWidgetCurrent )
{
printf( "Widget changed\r\n" ) ;
// Selected widget changed, repaint previous one
if ( pScreen->pWidgetOld != NULL )
{
WGT_Draw( pScreen->pWidgetOld, g_WGT_CoreData.pBE ) ;
}
g_WGT_CoreData.pBE->DrawRectangle( pWidget->dwX, pWidget->dwY, pWidget->dwX+pWidget->dwWidth-1, pWidget->dwY+pWidget->dwHeight-1, &clrSelection ) ;
pScreen->pWidgetOld=pScreen->pWidgetCurrent ;
}
return SAMGUI_E_OK ;
}
}
return SAMGUI_E_INVALID_WIDGET ;
}
//extern uint32_t WGT_Screen_SelectNextWidget( SWGTScreen* pScreen )
//{
// uint32_t dw ;
// uint32_t dwIndex=WGT_MAX_WIDGETS ;
// uint32_t dwIndexNext=WGT_MAX_WIDGETS ;
//
// SGUIColor clrSelection={ .u.dwRGBA=GUICLR_ATMEL_BLUE } ;
//
// if ( pScreen == NULL )
// {
// return SAMGUI_E_BAD_PARAMETER ;
// }
//
// for ( dw=0 ; dw < pScreen->dwWidgets ; dw++ )
// {
// if ( pScreen->apWidgets[dw] == pScreen->pWidgetCurrent )
// {
// // Got selected
// dwIndex=dw ;
// break ;
// }
// }
//
// // Did we find the current selected button?
// if ( dwIndex != WGT_MAX_WIDGETS )
// {
// // Find next button
// for ( dw=dwIndex ; dw < pScreen->dwWidgets ; dw++ )
// {
// if ( pScreen->apWidgets[dw]->dwType == WGT_TYPE_BUTTON )
// {
// // Got selected
// dwIndexNext=dw ;
// break ;
// }
// }
//
// }
//
// return SAMGUI_E_OK ;
//}
//
//extern uint32_t WGT_Screen_SelectPreviousWidget( SWGTScreen* pScreen )
//{
// return SAMGUI_E_OK ;
//}
extern uint32_t WGT_Screen_OnPaint( SWGTScreen* pScreen )
{
uint32_t dw ;
for ( dw=0 ; dw < pScreen->dwWidgets ; dw++ )
{
if ( pScreen->apWidgets[dw] )
{
WGT_Draw( pScreen->apWidgets[dw], g_WGT_CoreData.pBE ) ;
}
}
return SAMGUI_E_OK ;
}
extern uint32_t WGT_Screen_OnEraseBackground( SWGTScreen* pScreen )
{
if ( pScreen->pucBmpBackground == NULL )
{
SGUIColor clr={ .u.dwRGBA=pScreen->dwClrBackground } ;
g_WGT_CoreData.pBE->DrawFilledRectangle( 0, 0, BOARD_LCD_WIDTH, BOARD_LCD_HEIGHT, NULL, &clr ) ;
}
else
{
g_WGT_CoreData.pBE->DrawBitmap( 0, 0, BOARD_LCD_WIDTH, BOARD_LCD_HEIGHT, pScreen->pucBmpBackground ) ;
}
return SAMGUI_E_OK ;
}
#if 0
extern uint32_t WGT_Screen_SendMessageID( SWGTScreen* pScreen, uint32_t dwID, uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 )
{
SWGTCoreMessage sMsg ;
sMsg.dwID=dwMsgID ;
sMsg.dwParam1=dwParam1 ;
sMsg.dwParam2=dwParam2 ;
// Send message
if ( xQueueSendToFront( g_WGT_CoreData.hMessagesQueue, &sMsg, ( portTickType )10 ) != pdPASS )
{
return SAMGUI_E_MSQUEUE ;
}
return SAMGUI_E_OK ;
}
extern uint32_t WGT_Screen_SendMessageHdl( SWGTScreen* pScreen, SWGT_Widget* pWidget, uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 )
{
SWGTCoreMessage sMsg ;
sMsg.dwID=dwMsgID ;
sMsg.dwParam1=dwParam1 ;
sMsg.dwParam2=dwParam2 ;
// Send message
if ( xQueueSendToFront( g_WGT_CoreData.hMessagesQueue, &sMsg, ( portTickType )10 ) != pdPASS )
{
return SAMGUI_E_MSQUEUE ;
}
return SAMGUI_E_OK ;
}
extern uint32_t WGT_Screen_PostMessageID( SWGTScreen* pScreen, uint32_t dwID, uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 )
{
SWGTCoreMessage sMsg ;
sMsg.dwID=dwMsgID ;
sMsg.dwParam1=dwParam1 ;
sMsg.dwParam2=dwParam2 ;
// Post message
if ( xQueueSendToBack( g_WGT_CoreData.hMessagesQueue, &sMsg, ( portTickType )0 ) != pdPASS )
{
return SAMGUI_E_MSQUEUE ;
}
return SAMGUI_E_OK ;
}
extern uint32_t WGT_Screen_PostMessageHdl( SWGTScreen* pScreen, SWGT_Widget* pWidget, uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 )
{
SWGTCoreMessage sMsg ;
sMsg.dwID=dwMsgID ;
sMsg.dwParam1=dwParam1 ;
sMsg.dwParam2=dwParam2 ;
// Post message
if ( xQueueSendToBack( g_WGT_CoreData.hMessagesQueue, &sMsg, ( portTickType )0 ) != pdPASS )
{
return SAMGUI_E_MSQUEUE ;
}
return SAMGUI_E_OK ;
}
#endif // 0
@@ -0,0 +1,81 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
#ifndef _SAMGUI_WIDGET_CORE_SCREEN_
#define _SAMGUI_WIDGET_CORE_SCREEN_
#include "sam-gui/wgt/core/wgt_core_widget.h"
#include "sam-gui/wgt/core/wgt_core_message.h"
//#include "sam-gui/wgt/core/wgt_core.h"
#define WGT_MAX_WIDGETS 16
typedef struct _SWGTScreen
{
// Data members
SWGT_Widget* apWidgets[WGT_MAX_WIDGETS] ; // array of widgets
uint32_t dwWidgets ; // number of widgets
uint32_t dwClrBackground ; // screen background color
uint8_t* pucBmpBackground ; // screen background bitmap
SWGT_Widget* pWidgetOld ; // previously selected widget
SWGT_Widget* pWidgetCurrent ; // current selected widget
// Callbacks
uint32_t (*ProcessMessage)( struct _SWGTScreen* pScreen, SWGTCoreMessage* pMsg ) ;
uint32_t (*OnInitialize)( struct _SWGTScreen* pScreen ) ;
uint32_t (*OnEraseBackground)( struct _SWGTScreen* pScreen ) ;
uint32_t (*OnPaint)( struct _SWGTScreen* pScreen ) ;
} SWGTScreen ;
// ------------------------------------------------------------------------------------------------
// Screen functions
extern uint32_t WGT_Screen_Initialize( SWGTScreen* pScreen, uint32_t dwClrBackground, uint8_t* pvBmpBackground ) ;
extern uint32_t WGT_Screen_AddWidget( SWGTScreen* pScreen, SWGT_Widget* pWidget ) ;
extern uint32_t WGT_Screen_GetPointedWidget( SWGTScreen* pScreen, uint32_t dwX, uint32_t dwY, SWGT_Widget** ppWidget ) ;
extern uint32_t WGT_Screen_GetSelectedWidget( SWGTScreen* pScreen, SWGT_Widget** ppWidget ) ;
extern uint32_t WGT_Screen_SetSelectedWidget( SWGTScreen* pScreen, SWGT_Widget* pWidget ) ;
//extern uint32_t WGT_Screen_SelectNextWidget( SWGTScreen* pScreen ) ;
//extern uint32_t WGT_Screen_SelectPreviousWidget( SWGTScreen* pScreen ) ;
//
extern uint32_t WGT_Screen_OnPaint( SWGTScreen* pScreen ) ;
extern uint32_t WGT_Screen_OnEraseBackground( SWGTScreen* pScreen ) ;
#if 0
extern uint32_t WGT_Screen_SendMessageID( SWGTScreen* pScreen, uint32_t dwID, uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 ) ;
extern uint32_t WGT_Screen_SendMessageHdl( SWGTScreen* pScreen, SWGT_Widget* pWidget, uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 ) ;
extern uint32_t WGT_Screen_PostMessageID( SWGTScreen* pScreen, uint32_t dwID, uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 ) ;
extern uint32_t WGT_Screen_PostMessageHdl( SWGTScreen* pScreen, SWGT_Widget* pWidget, uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 ) ;
#endif // 0
#endif // _SAMGUI_WIDGET_CORE_SCREEN_
@@ -0,0 +1,33 @@
#include "sam-gui/wgt/core/wgt_core_timer.h"
#include "porting/sam_gui_porting.h"
#include "sam-gui/common/sam_gui_errors.h"
#include <string.h>
static __no_init SWGTTimer* gs_apWGTTimers[WGT_TIMER_MAX] ;
extern uint32_t WGT_Timer_Create( SWGTTimer* pTimer, uint32_t dwID, uint32_t dwDelay )
{
return SAMGUI_E_OK ;
}
extern uint32_t WGT_Timer_Start( SWGTTimer* pTimer )
{
return SAMGUI_E_OK ;
}
extern uint32_t WGT_Timer_Stop( SWGTTimer* pTimer )
{
return SAMGUI_E_OK ;
}
extern uint32_t WGT_Timer_Initialize( void )
{
memset( gs_apWGTTimers, 0, sizeof( gs_apWGTTimers ) ) ;
return SAMGUI_E_OK ;
}
extern uint32_t WGT_Timer_Process( void )
{
return SAMGUI_E_OK ;
}
@@ -0,0 +1,63 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
#ifndef _SAMGUI_WIDGET_CORE_TIMER_
#define _SAMGUI_WIDGET_CORE_TIMER_
//#include "sam-gui/wgt/core/wgt_core_message.h"
//#include "sam-gui/wgt/core/wgt_core.h"
// Max available timers
#define WGT_TIMER_MAX 4
typedef enum _eWGTTimer_State
{
WGT_TIMER_DISABLED, // 0
WGT_TIMER_ENABLED
} eWGTTimer_State ;
typedef struct _SWGTTimer
{
uint32_t dwState ;
uint32_t dwID ;
uint32_t dwDelay ;
uint32_t dwTimestamp ;
} SWGTTimer ;
// ------------------------------------------------------------------------------------------------
// Timer functions
extern uint32_t WGT_Timer_Create( SWGTTimer* pTimer, uint32_t dwID, uint32_t dwDelay ) ;
extern uint32_t WGT_Timer_Start( SWGTTimer* pTimer ) ;
extern uint32_t WGT_Timer_Stop( SWGTTimer* pTimer ) ;
extern uint32_t WGT_Timer_Initialize( void ) ;
extern uint32_t WGT_Timer_Process( void ) ;
#endif // _SAMGUI_WIDGET_CORE_TIMER_
@@ -0,0 +1,225 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
#include "sam-gui/wgt/core/wgt_core_widget.h"
#include "sam-gui/common/sam_gui_errors.h"
#include "sam-gui/file/file_fs.h"
#include "drivers/utility/bmp.h"
#include "freertos.h"
#include <string.h>
#include <stdio.h>
// ------------------------------------------------------------------------------------------------
// Widget functions
// ------------------------------------------------------------------------------------------------
extern uint32_t WGT_CreateWidget( SWGT_Widget* pWidget, WGT_Type eType, uint32_t dwX, uint32_t dwY, uint32_t dwWidth, uint32_t dwHeight )
{
if ( pWidget == NULL )
{
return SAMGUI_E_BAD_POINTER ;
}
memset( pWidget, 0, sizeof( SWGT_Widget ) ) ;
pWidget->dwType=eType ;
pWidget->dwX=dwX ;
pWidget->dwY=dwY ;
pWidget->dwWidth=dwWidth ;
pWidget->dwHeight=dwHeight ;
return SAMGUI_E_OK ;
}
extern uint32_t WGT_SetBkgndColor( SWGT_Widget* pWidget, uint32_t dwColor )
{
if ( pWidget == NULL )
{
return SAMGUI_E_BAD_POINTER ;
}
pWidget->dwClrBackground=dwColor ;
return SAMGUI_E_OK ;
}
extern uint32_t WGT_SetTextColor( SWGT_Widget* pWidget, uint32_t dwColor )
{
if ( pWidget == NULL )
{
return SAMGUI_E_BAD_POINTER ;
}
pWidget->dwClrText=dwColor ;
return SAMGUI_E_OK ;
}
extern uint32_t WGT_SetText( SWGT_Widget* pWidget, char* pszText )
{
if ( (pWidget == NULL) || (pszText == NULL) )
{
return SAMGUI_E_BAD_POINTER ;
}
pWidget->pvText=pszText ;
return SAMGUI_E_OK ;
}
extern uint32_t WGT_SetBitmap( SWGT_Widget* pWidget, uint8_t* pucBitmap )
{
if ( (pWidget == NULL) || (pucBitmap == NULL) )
{
return SAMGUI_E_BAD_POINTER ;
}
pWidget->pvBitmap=pucBitmap ;
return SAMGUI_E_OK ;
}
//static uint32_t WGT_DrawBMPFile( SWGT_Widget* pWidget, SDISPBackend* pBE )
//{
// uint32_t dwLine ;
// uint8_t* pucLine=NULL ;
// FIL fp ;
// struct BMPHeader sHeader ;
// uint32_t dwLineLength ;
// uint32_t dwLength ;
// uint32_t dwTemp ;
//
// if ( (pWidget == NULL) || (pBE == NULL) )
// {
// return SAMGUI_E_BAD_POINTER ;
// }
//
// // Read first 256 bytes to obtain header
// if ( f_open( &fp, pWidget->pvBitmap, FA_OPEN_EXISTING|FA_READ ) == FR_OK )
// {
// if ( f_read( &fp, &sHeader, sizeof( sHeader ), &dwLength ) == FR_OK )
// {
//// printf( "read %c%c\r\n", (char)(sHeader.type&0xff), (char)(sHeader.type>>8) ) ;
//// printf( " -> .compression = %u\n\r", sHeader.compression ) ;
//// printf( " -> .width = %u\n\r", sHeader.width ) ;
//// printf( " -> .height = %u\n\r", sHeader.height ) ;
//// printf( " -> .bits = %u\n\r", sHeader.bits ) ;
//
// dwLineLength=(((sHeader.width*sHeader.bits)+31)/32)*4 ;
// printf( "free heap %u, needed %u\r\n", xPortGetFreeHeapSize(), dwLineLength ) ;
//
// // if header is Windows BMP 24bpp, alloc line size bytes on HEAP
// if ( (sHeader.bits == 24) ) //&& (dwLineLength >= xPortGetFreeHeapSize()) )
// {
// // Allocate line buffer
// pucLine=pvPortMalloc( dwLineLength ) ;
// if ( pucLine )
// {
// // Move file pointer to begin of BMP data
// f_lseek( &fp, sHeader.offset ) ;
//
// // Read each bitmap line and write it on backend
// for ( dwLine=0 ; dwLine < pWidget->dwHeight ; dwLine++ )
// {
// if ( f_read( &fp, pucLine, dwLineLength, &dwLength ) == FR_OK )
// {
// for ( dwLength=0 ; dwLength < dwLineLength ; dwLength+=3 )
// {
// dwTemp=pucLine[dwLength] ; ;
// pucLine[dwLength]=pucLine[dwLength+2] ;
// pucLine[dwLength+2]=dwTemp ; ;
// }
//
// pBE->DrawBitmap( pWidget->dwX, pWidget->dwY+pWidget->dwHeight-dwLine, pWidget->dwWidth, 1, pucLine ) ;
// }
// }
//
// // Free line buffer
// vPortFree( pucLine ) ;
// }
// }
// }
// else
// {
// printf( "failed to read\r\n" ) ;
// }
// f_close( &fp ) ;
// return SAMGUI_E_OK ;
// }
// else
// {
// printf( "failed to open %s\r\n", pWidget->pvBitmap ) ;
// }
//
// return SAMGUI_E_FILE_OPEN ;
//}
extern uint32_t WGT_Draw( SWGT_Widget* pWidget, SDISPBackend* pBE )
{
SGUIColor clr ;
if ( (pWidget == NULL) || (pBE == NULL) )
{
return SAMGUI_E_BAD_POINTER ;
}
// if bitmap declared, draw it
if ( pWidget->pvBitmap != NULL )
{
// Check whether if bitmap is on external FS or internal RAM
// if ( ((uint8_t*)(pWidget->pvBitmap))[0] == '/' )
// {
// if ( WGT_DrawBMPFile( pWidget, pBE ) != SAMGUI_E_OK )
// {
// clr.u.dwRGBA=pWidget->dwClrBackground ;
//
// pBE->DrawFilledRectangle( pWidget->dwX, pWidget->dwY, pWidget->dwX+pWidget->dwWidth, pWidget->dwY+pWidget->dwHeight, NULL, &clr ) ;
// }
// }
// else
// {
pBE->DrawBitmap( pWidget->dwX, pWidget->dwY, pWidget->dwWidth, pWidget->dwHeight, pWidget->pvBitmap ) ;
// }
}
// else if colors, draw background color filled rectangle
else
{
clr.u.dwRGBA=pWidget->dwClrBackground ;
pBE->DrawFilledRectangle( pWidget->dwX, pWidget->dwY, pWidget->dwX+pWidget->dwWidth, pWidget->dwY+pWidget->dwHeight, NULL, &clr ) ;
}
// if label declared, draw text
if ( (pWidget->pvText != NULL) && (pWidget->dwType == WGT_TYPE_TEXT) )
{
clr.u.dwRGBA=pWidget->dwClrText ;
pBE->DrawText( pWidget->dwX, pWidget->dwY, pWidget->pvText, &clr, (void*)&g_Font10x14, 0 ) ;
}
return SAMGUI_E_OK ;
}
@@ -0,0 +1,99 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
#ifndef _SAMGUI_WGT_CORE_WIDGET_
#define _SAMGUI_WGT_CORE_WIDGET_
#include "disp/disp_backend.h"
typedef enum _WGT_Type
{
WGT_TYPE_BUTTON,
WGT_TYPE_TEXT,
WGT_TYPE_BITMAP,
WGT_TYPE_SLIDER,
WGT_TYPE_MAX
} WGT_Type ;
typedef enum _WGT_Status
{
WGT_STATUS_NORMAL,
WGT_STATUS_SELECTED,
WGT_STATUS_HIDDEN,
WGT_STATUS_MAX
} WGT_Status ;
typedef enum _WGT_Style
{
WGT_STYLE_NONE,
WGT_STYLE_TEXT_LEFT,
WGT_STYLE_TEXT_RIGHT,
WGT_STYLE_TEXT_JUSTIFIED,
WGT_STYLE_MAX
} WGT_Style ;
typedef struct _SWGT_Widget
{
WGT_Type dwType ; // Widget type
uint32_t dwID ; // Widget unique ID
struct _SWGT_Widget* pParent ;
struct _SWGT_Widget* pSibling ;
struct _SWGT_Widget* pChild ;
uint32_t dwX ;
uint32_t dwY ;
uint32_t dwWidth ;
uint32_t dwHeight ;
uint32_t dwClrText ;
uint32_t dwClrBackground ;
WGT_Style dwStyle ;
void* pvBitmap ;
void* pvFont ;
void* pvText ;
WGT_Status dwStatus ;
} SWGT_Widget ;
// ------------------------------------------------------------------------------------------------
// Widget functions
extern uint32_t WGT_CreateWidget( SWGT_Widget* pWidget, WGT_Type eType, uint32_t dwX, uint32_t dwY, uint32_t dwWidth, uint32_t dwHeight ) ;
extern uint32_t WGT_SetBkgndColor( SWGT_Widget* pWidget, uint32_t dwColor ) ;
extern uint32_t WGT_SetTextColor( SWGT_Widget* pWidget, uint32_t dwColor ) ;
extern uint32_t WGT_SetText( SWGT_Widget* pWidget, char* pszText ) ;
extern uint32_t WGT_SetBitmap( SWGT_Widget* pWidget, uint8_t* pucBitmap ) ;
//extern uint32_t WGT_DrawBMPFile( SWGT_Widget* pWidget, SDISPBackend* pBE ) ;
extern uint32_t WGT_Draw( SWGT_Widget* pWidget, SDISPBackend* pBE ) ;
#endif // _SAMGUI_WGT_CORE_WIDGET_
@@ -0,0 +1,303 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
#include "sam-gui/wgt/frontends/frontend_ADS7843.h"
#include "sam-gui/common/sam_gui_errors.h"
#include "board.h"
#include "pio/pio.h"
#include "pio/pio_it.h"
#include "tsd/tsd_ads7843.h"
#include "demo_parameters.h"
#include "sam-gui/porting/sam_gui_porting.h"
#include "sam-gui/wgt/core/wgt_core_message.h"
#include "components/ads7843/ads7843.h"
/* RTOS operations */
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
#include <stdio.h>
#include <string.h>
/** \addtogroup Demo_Touchscreen Touchscreen driver
* The Touchscreen driver posts messages to the Widget message queue:
* <ul>
* <li>WGT_MSG_POINTER_RAW: pen pressed, provides uncalibrated-filtered pen position. </li>
* <li>WGT_MSG_POINTER_PRESSED: pen pressed, provides calibrated-filtered pen position.</li>
* <li>WGT_MSG_POINTER: pen moved, provides calibrated-filtered pen position.</li>
* <li>WGT_MSG_POINTER_RELEASED: pen released, provides calibrated-filtered pen position.</li>
* \n
*
* Touchscreen ADS7843 is connected to the microcontroller through SPI and an
* a signal connected to a PIO corresponding to the pen press detection.
* Each time a pen press is detected, the microcontroller is notified thrrough
* the interrupt line triggering a PIO interrupt.
* \n
*
* The touchscreen driver starts a task suspended until the PIO interrupt
* handler releases a semaphore. Then the task does measurements until the pen
* is detected as released.
* Once the pen is released, the task enters in suspend mode, waiting to get the
* semaphore ie. waiting for the next pen press detection.
*
* Related files :\n
* \ref ads7843.c\n
* \ref ads7843.h\n
*/
/*
* ----------------------------------------------------------------------------
* Touchscreen driver parameters
* ----------------------------------------------------------------------------
*/
#define NB_SAMPLES 3 /**< Number of succesive measurements required to get an accurate pen position */
#define SAMPLING_PERIOD 10 /**< Sampling period (in ms) when pen is pressed to detect pen mouvements */
/** Binary flag to check if the screen has been calibrated. Calibration calculus
* is not applied since this flag is not true.
* Only raw values are sent to the application until the calibration has been
* done */
uint8_t gTsCalibrated = 0;
static Ads7843CalibParameters gs_ADS7843CalibParameters;
/** Pins used by Interrupt Signal for Touch Screen Controller */
static const Pin _WFE_ADS7843_pinPenIRQ=PIN_TCS_IRQ ;
/** Touch screen semaphore used to resume touch screen task when pen is pressed */
static xSemaphoreHandle gTsSemaphore = NULL;
/**
* \brief Returns Touchscreen pen position
* Performs several (NB_SAMPLES succesive measurements and do a mean. Then
* calibration function is applied according to the calibration parameters.
*/
static void _WFE_ADS7843_GetPenPosition(uint32_t *pdwX, uint32_t *pdwY)
{
uint32_t i;
uint32_t dwX, dwY; /* Measured coordinates */
uint32_t dwTrueX, dwTrueY; /* Filtered coordinates */
/* Do several successive measurements and process a mean */
dwTrueX = 0;
dwTrueY = 0;
for (i = 0; i < NB_SAMPLES; ++i) {
ADS7843_GetPosition( &dwX, &dwY ) ;
dwTrueX += dwX;
dwTrueY += dwY;
}
dwTrueX /= NB_SAMPLES;
dwTrueY /= NB_SAMPLES;
/* If calibration has been done, apply calibration function */
if (gTsCalibrated) {
dwTrueX = gs_ADS7843CalibParameters.dwPointX
- ((int32_t)(gs_ADS7843CalibParameters.dwMeasureX - (int32_t)dwTrueX) * 1024)
/ gs_ADS7843CalibParameters.lSlopeX ;
dwTrueY = gs_ADS7843CalibParameters.dwPointY
- ((int32_t)(gs_ADS7843CalibParameters.dwMeasureY - (int32_t)dwTrueY) * 1024)
/ gs_ADS7843CalibParameters.lSlopeY ;
if ((int32_t)dwTrueX < 0 ) /* Is pPoint[0] negative ? */
dwTrueX = 0;
if ( dwTrueX > BOARD_LCD_WIDTH ) /* Is pPoint[0] bigger than the LCD width ? */
dwTrueX = BOARD_LCD_WIDTH ;
if ((int32_t)dwTrueY < 0 ) /* Is pPoint[0] negative ? */
dwTrueY = 0;
if ( dwTrueY > BOARD_LCD_HEIGHT ) /* Is pPoint[0] bigger than the LCD width ? */
dwTrueY = BOARD_LCD_HEIGHT ;
}
/* Update pen position coordinates */
*pdwX = dwTrueX;
*pdwY = dwTrueY;
}
/**
* \brief Touch screen sampling task
*
* This task is resumed when a PIO interrupt release the semaphore, that's to
* say when the pen is pressed. Then this task reports pen activity each
* SAMPLING_RATE period until the pen is released
*/
static void _WFE_ADS7843_Task( void* pParameter )
{
uint8_t isPenPressed;
uint32_t dwX, dwPrevX;
uint32_t dwY, dwPrevY;
while (1) {
/* Block waiting for the semaphore to become available: */
/* A PIO interrupt has been triggered: a key has been pressed */
if( xSemaphoreTake( gTsSemaphore, portMAX_DELAY ) != pdTRUE )
continue;
/* Add a delay between interrupt and data acquisition */
vTaskDelay( 5 );
isPenPressed = 1;
/* Perform a first measurement corresponding to the key pressed */
_WFE_ADS7843_GetPenPosition(&dwX, &dwY);
/* If it is not calibrated send the raw value to the application */
if (!gTsCalibrated) {
WGT_SendMessageISR( WGT_MSG_POINTER_RAW, dwX, dwY);
isPenPressed = 0;
}
else {
/* Send the key pressed position */
WGT_SendMessageISR( WGT_MSG_POINTER_PRESSED, dwX, dwY) ;
dwPrevX = dwX;
dwPrevY = dwY;
}
/* Perform measurements at SAMPLING_RATE while the key is pressed */
while (isPenPressed) {
vTaskDelay( SAMPLING_PERIOD/portTICK_RATE_MS ) ;
/* Perform measurements at SAMPLING_RATE */
_WFE_ADS7843_GetPenPosition(&dwX, &dwY);
/* If the touch has been released exit the loop and post release message */
if ( PIO_Get( &_WFE_ADS7843_pinPenIRQ ) == 1) {
WGT_SendMessageISR( WGT_MSG_POINTER_RELEASED, dwPrevX, dwPrevY) ;
isPenPressed = 0;
}
/* Else send the pen position if this one is different from the previous one */
else if ( (dwX != dwPrevX) || (dwY != dwPrevY) ) {
WGT_SendMessageISR( WGT_MSG_POINTER, dwX, dwY) ;
dwPrevX = dwX;
dwPrevY = dwY;
}
}
/* Loop and wait for PIO ISR to release the semaphore */
/* Enable the PIO interrupt */
PIO_EnableIt( &_WFE_ADS7843_pinPenIRQ ) ;
}
}
/**
* \brief Interrupt handler for Touchscreen.
*/
#ifdef BOARD_REV_A
void PIOA_Irq4Handler(unsigned char id)
#endif
#ifdef BOARD_REV_B
void PIOA_Irq16Handler(unsigned char id)
#endif
{
portBASE_TYPE xHigherPriorityTaskWoken;
/* A posedge has been received */
xSemaphoreGiveFromISR( gTsSemaphore, &xHigherPriorityTaskWoken );
PIO_DisableIt( &_WFE_ADS7843_pinPenIRQ ) ;
}
static uint32_t _WFE_ADS7843_Initialize( void )
{
// Initialize touchscreen
ADS7843_Initialize() ;
/* Configure pios */
PIO_Configure( &_WFE_ADS7843_pinPenIRQ, PIO_LISTSIZE( _WFE_ADS7843_pinPenIRQ ) ) ;
/* Create the semaphore required for pen detection */
vSemaphoreCreateBinary( gTsSemaphore );
if( gTsSemaphore == NULL )
return SAMGUI_E_NOT_ENOUGH_MEMORY;
/* Take the semaphore, this one will be release in the PIO ISR handler, once the pen will be pressed */
if( xSemaphoreTake( gTsSemaphore, 0 ) != pdTRUE )
return SAMGUI_E_NOT_ENOUGH_MEMORY; /* TODO: change return code, it shall correspond to initialization error */
/* Get calibration parameters */
gs_ADS7843CalibParameters.dwPointX = g_demo_parameters.sCalibration.dwPointX;
gs_ADS7843CalibParameters.dwPointY = g_demo_parameters.sCalibration.dwPointY;
gs_ADS7843CalibParameters.dwMeasureX = g_demo_parameters.sCalibration.dwMeasureX;
gs_ADS7843CalibParameters.dwMeasureY = g_demo_parameters.sCalibration.dwMeasureY;
gs_ADS7843CalibParameters.lSlopeX = g_demo_parameters.sCalibration.lSlopeX;
gs_ADS7843CalibParameters.lSlopeY = g_demo_parameters.sCalibration.lSlopeY;
/* Check if we already have calibration data */
if (gs_ADS7843CalibParameters.dwPointX) {
gTsCalibrated = 1;
}
/* Enable the PIO interrupt */
PIO_EnableIt( &_WFE_ADS7843_pinPenIRQ ) ;
/* Create the touch screen driver task */
if (xTaskCreate( _WFE_ADS7843_Task, "WGT_Core_TS", 512, NULL, tskIDLE_PRIORITY+2, NULL ) != pdPASS)
return SAMGUI_E_NOT_ENOUGH_MEMORY;
return SAMGUI_E_OK ;
}
static uint32_t _WFE_ADS7843_IOCtl( uint32_t dwCommand, uint32_t* pdwValue, uint32_t* pdwValueLength )
{
switch (dwCommand) {
case WGT_FRONTEND_IOCTL_SET_DATA:
if ( (pdwValueLength != NULL) && (*pdwValueLength == sizeof( Ads7843CalibParameters )) )
{
memcpy( &gs_ADS7843CalibParameters, pdwValue, sizeof( Ads7843CalibParameters ) ) ;
if ( gs_ADS7843CalibParameters.lSlopeX != 0 )
{
gTsCalibrated=1 ;
}
else
{
gTsCalibrated=0 ;
}
}
break;
default:
break;
}
return SAMGUI_E_OK ;
}
const SWGTFrontend sWGT_Frontend_ADS7843=
{
.sData={ .dwId=WGT_FRONTEND_ADS7843 },
.Initialize=_WFE_ADS7843_Initialize,
.IOCtl=_WFE_ADS7843_IOCtl
} ;
@@ -0,0 +1,52 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
#ifndef _WGT_FRONTEND_ADS7843_
#define _WGT_FRONTEND_ADS7843_
#include "sam-gui/wgt/core/wgt_core_frontend.h"
typedef struct _Ads7843CalibParameters
{
uint32_t dwPointX;
uint32_t dwPointY;
uint32_t dwMeasureX;
uint32_t dwMeasureY;
int32_t lSlopeX;
int32_t lSlopeY;
} Ads7843CalibParameters;
/*----------------------------------------------------------------------------
* Exported functions
*----------------------------------------------------------------------------*/
extern const SWGTFrontend sWGT_Frontend_ADS7843 ;
#endif // _WGT_FRONTEND_ADS7843_
@@ -0,0 +1,220 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
/** \addtogroup Demo_Potentiomer Potentiometer driver
* The Potentiometer driver posts messages to the Widget message queue.
* \n
*
* Board pontentiometer is connected to the 12 bit ADC analog line. Each time the
* user turns the potentiometer, it triggers an interrupt which posts a message
* with a value from 0 to 255 corresponding to the measurement.
*
* The SAMPLING_PERIOD definition controls the sampling frequency. A timer
* counter in waveform mode is used to trigger acquisitions. It is configured to
* count from the Slow clock frequency.
*
* The window mode of the ADC is used to trigger an ADC interrupt only when the
* measure goes outside a window controlled by the NB_INTERVALS definition.
*
* Each time a new ADC interrupt occurs, a new window is calculated from the current
* measurement.
*
* During the initialization a first measure is done to get the initial value.
* Application can have access to the current measure using ioctl command.
*
* For more accurate information, please look at the ADC section of the
* Datasheet.
*
* Related files :\n
* \ref adc.c\n
* \ref adc.h\n
*/
#include <stdint.h>
#include "sam-gui/wgt/frontends/frontend_potentiometer.h"
#include "sam-gui/common/sam_gui_errors.h"
#include "sam-gui/wgt/core/wgt_core_message.h"
#include <cmsis/core_cm3.h>
#include <board.h>
#include <pmc/pmc.h>
#include <adc/adc.h>
#include <tc/tc.h>
/* A message is posted each time the values goes outside the [-5,+5] interval around the previous measure */
#define NB_INTERVALS 5
/** ADC clock */
#define BOARD_ADC_FREQ (6000000)
/** ADC sampling period: 10 times/sec */
#define SAMPLING_PERIOD 32768/10
static uint32_t gdwPotentiometerValue;
/**
* \brief TC0 configuration
*
* Configures Timer Counter 0 (TC0) to generate an interrupt every second.
*
*/
static void ConfigureTc0(void)
{
/* Enable TC0 peripheral clock*/
PMC_EnablePeripheral(ID_TC0);
/* Configure TC for a 1s (= 1Hz) tick*/
TC_Configure(TC0,0, 0x4 | TC_CMR0_ACPC_SET | TC_CMR0_WAVE
| TC_CMR0_ACPA_CLEAR | (0x2 << 13));
/* 50% duty ,1s frequency*/
TC0->TC_CHANNEL[0].TC_RA = SAMPLING_PERIOD/2;
TC0->TC_CHANNEL[0].TC_RC = SAMPLING_PERIOD;
}
void ADC_IrqHandler(void)
{
Adc *pAdc = ADC;
int32_t dwLowPotThreshold, dwHighPotThreshold;
volatile uint32_t dummy = 0;
/* Read the status to ack the IT */
dummy = ADC_GetStatus(ADC);
/* Get the potentiometer initial value */
gdwPotentiometerValue = ADC_GetConvertedData(pAdc, ADC_CHANNEL_5);
/* Read LCDR to clear DRDY bit */
dummy = ADC_GetLastConvertedData(pAdc);
/* Set Window threshold according to the initial values */
dwLowPotThreshold = gdwPotentiometerValue - (NB_INTERVALS * (0x1000 / 256));
if (dwLowPotThreshold < 0)
dwLowPotThreshold = 0;
dwHighPotThreshold = gdwPotentiometerValue + (NB_INTERVALS * (0x1000 / 256));
if (dwHighPotThreshold >= 0x1000)
dwHighPotThreshold = 0x1000 - 1;
/* Normalize the value 0 -> 255 */
gdwPotentiometerValue = (gdwPotentiometerValue * 256) / 0xFFF;
/* Post Message */
WGT_SendMessageISR( WGT_MSG_KEY_PRESSED, WGT_KEY_VR1, 255 - gdwPotentiometerValue ) ;
/* Setup Threshold*/
ADC_SetComparisonWindow(pAdc,((dwHighPotThreshold<<16)|dwLowPotThreshold));
}
static uint32_t _WFE_Potentiometer_Initialize( void )
{
Adc *pAdc = ADC;
int32_t dwLowPotThreshold, dwHighPotThreshold;
/* STEP1: Realize a first measure to get potentiometer's initial position */
/* Initialize ADC*/
ADC_Initialize( pAdc,ID_ADC, ADC_MR_TRGEN_DIS,/*HARDWARE trigger*/
0,ADC_MR_SLEEP_NORMAL,ADC_MR_LOWRES_12_BIT,
BOARD_MCK,BOARD_ADC_FREQ,10,20);
/*Enable channel 5 (potentiometer) */
ADC_EnableChannel(pAdc, ADC_CHANNEL_5);
/* Start convrsion */
ADC_StartConversion(pAdc);
/* Wait for the end of conversion */
while ( !(ADC_GetStatus(pAdc) & ADC_ISR_EOC5) ) {}
/* Get the potentiometer initial value */
gdwPotentiometerValue = ADC_GetConvertedData(pAdc, ADC_CHANNEL_5);
/* Set Window threshold according to the initial values */
dwLowPotThreshold = gdwPotentiometerValue - (NB_INTERVALS * (0x1000 / 256));
if (dwLowPotThreshold < 0)
dwLowPotThreshold = 0;
dwHighPotThreshold = gdwPotentiometerValue + (NB_INTERVALS * (0x1000 / 256));
if (dwHighPotThreshold >= 0x1000)
dwHighPotThreshold = 0x1000 - 1;
/* Normalize the value 0 -> 255 */
gdwPotentiometerValue = (gdwPotentiometerValue * 256) / 0xFFF;
/* STEP2: Re configure ADC to use windowing */
/* Initialize ADC*/
ADC_Initialize( pAdc,ID_ADC, ADC_MR_TRGEN_EN,/*HARDWARE trigger*/
ADC_MR_TRGSEL_TIOA0,ADC_MR_SLEEP_NORMAL,ADC_MR_LOWRES_12_BIT,
BOARD_MCK,BOARD_ADC_FREQ,10,20);
/*Enable channel 5 (potentiometer) */
ADC_EnableChannel(pAdc, ADC_CHANNEL_5);
/* Configure TC*/
ConfigureTc0();
/*Channel 5 has to be compared*/
ADC_SetCompareChannel(pAdc, ADC_CHANNEL_5);
/*Compare mode, in the window*/
ADC_SetCompareMode(pAdc, ADC_EMR_CMPMODE_OUT);
/* Setup Threshold*/
ADC_SetComparisonWindow(pAdc,((dwHighPotThreshold<<16)|dwLowPotThreshold));
/* enable adc interrupt*/
NVIC_EnableIRQ(ADC_IRQn);
/* Enable Compare Interrupt*/
ADC_EnableIt(pAdc, ADC_IDR_COMPE);
/* Start TC0 and hardware trigger*/
TC_Start(TC0,0);
return SAMGUI_E_OK ;
}
static uint32_t _WFE_Potentiometer_IOCtl( uint32_t dwCommand, uint32_t* pdwValue, uint32_t* pdwValueLength )
{
/* Return the current potentiometer value */
if (pdwValue) {
*pdwValue = gdwPotentiometerValue;
if (pdwValueLength)
*pdwValueLength = sizeof(gdwPotentiometerValue);
}
return SAMGUI_E_OK ;
}
const SWGTFrontend sWGT_Frontend_Potentiometer=
{
.sData={ .dwId=WGT_FRONTEND_POTENTIOMETER },
.Initialize=_WFE_Potentiometer_Initialize,
.IOCtl=_WFE_Potentiometer_IOCtl
} ;
@@ -0,0 +1,42 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
#ifndef _WGT_FRONTEND_POTENTIOMETER_
#define _WGT_FRONTEND_POTENTIOMETER_
#include "sam-gui/wgt/core/wgt_core_frontend.h"
/*----------------------------------------------------------------------------
* Exported functions
*----------------------------------------------------------------------------*/
extern const SWGTFrontend sWGT_Frontend_Potentiometer ;
#endif // _WGT_FRONTEND_POTENTIOMETER_
@@ -0,0 +1,66 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
/* PIO functions */
#include <pio/pio.h>
#include <pio/pio_it.h>
#include "sam-gui/wgt/frontends/frontend_pushbuttons.h"
#include "sam-gui/wgt/core/wgt_core_message.h"
#include "sam-gui/common/sam_gui_errors.h"
/** VBus pin instance. */
const Pin gPinButton1 = PIN_PUSHBUTTON_1;
const Pin gPinButton2 = PIN_PUSHBUTTON_2;
static uint32_t _WFE_PushButtons_Initialize( void )
{
/* Configure PIO */
PIO_Configure(&gPinButton1, 1);
PIO_Configure(&gPinButton2, 1);
/* Enable PIO interrupt */
PIO_EnableIt(&gPinButton1);
PIO_EnableIt(&gPinButton2);
return SAMGUI_E_OK ;
}
static uint32_t _WFE_PushButtons_IOCtl( uint32_t dwCommand, uint32_t* pdwValue, uint32_t* pdwValueLength )
{
return SAMGUI_E_OK ;
}
const SWGTFrontend sWGT_Frontend_PushButtons=
{
.sData={ .dwId=WGT_FRONTEND_PUSHBUTTONS },
.Initialize=_WFE_PushButtons_Initialize,
.IOCtl=_WFE_PushButtons_IOCtl
} ;
@@ -0,0 +1,49 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
#ifndef _WGT_FRONTEND_PUSHBUTTONS_
#define _WGT_FRONTEND_PUSHBUTTONS_
/* PIO functions */
#include <pio/pio.h>
#include "sam-gui/wgt/core/wgt_core_frontend.h"
extern const Pin gPinButton1;
extern const Pin gPinButton2;
/*----------------------------------------------------------------------------
* Exported functions
*----------------------------------------------------------------------------*/
extern const SWGTFrontend sWGT_Frontend_PushButtons ;
extern void WFE_Button1Handler(unsigned char id);
#endif // _WGT_FRONTEND_PUSHBUTTONS_
@@ -0,0 +1,50 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
#include "sam-gui/wgt/frontends/frontend_qtouch.h"
#include "sam-gui/common/sam_gui_errors.h"
static uint32_t _WFE_QTouch_Initialize( void )
{
return SAMGUI_E_OK ;
}
static uint32_t _WFE_QTouch_IOCtl( uint32_t dwCommand, uint32_t* pdwValue, uint32_t* pdwValueLength )
{
return SAMGUI_E_OK ;
}
const SWGTFrontend sWGT_Frontend_QTouch=
{
.sData={ .dwId=WGT_FRONTEND_QTOUCH },
.Initialize=_WFE_QTouch_Initialize,
.IOCtl=_WFE_QTouch_IOCtl
} ;
@@ -0,0 +1,42 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2009, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
#ifndef _WGT_FRONTEND_QTOUCH_
#define _WGT_FRONTEND_QTOUCH_
#include "sam-gui/wgt/core/wgt_core_frontend.h"
/*----------------------------------------------------------------------------
* Exported functions
*----------------------------------------------------------------------------*/
extern const SWGTFrontend sWGT_Frontend_QTouch ;
#endif // _WGT_FRONTEND_QTOUCH_
@@ -0,0 +1 @@
#include "sam-gui/wgt/widgets/wgt_widget_button.h"
@@ -0,0 +1,5 @@
#ifndef _SAMGUI_WIDGET_BUTTON_
#define _SAMGUI_WIDGET_BUTTON_
#endif // _SAMGUI_WIDGET_BUTTON_
@@ -0,0 +1 @@
#include "sam-gui/wgt/widgets/wgt_widget_static.h"
@@ -0,0 +1,5 @@
#ifndef _SAMGUI_WIDGET_STATIC_
#define _SAMGUI_WIDGET_STATIC_
#endif // _SAMGUI_WIDGET_STATIC_