# HG changeset patch # User jeandet # Date 2013-05-15 06:02:32 # Node ID 144bdeadc77a558201b71947eeca6eb7b4a5f32e # Parent 58c317327c7ed4d5506b7f431ff4a898d3536862 Added graphical terminal (first shot). diff --git a/examples/examples.pro b/examples/examples.pro --- a/examples/examples.pro +++ b/examples/examples.pro @@ -6,7 +6,8 @@ SUBDIRS += QtTest/test.pro \ STM32F4IT \ M4StickV2 \ lcdHello \ - BeagleSynthHello + BeagleSynthHello \ + lcdTerminal diff --git a/examples/lcdHello/main.c b/examples/lcdHello/main.c --- a/examples/lcdHello/main.c +++ b/examples/lcdHello/main.c @@ -11,7 +11,7 @@ #include #include #include - +#include extern streamdevice* __opnfiles__[]; @@ -69,6 +69,7 @@ int main() ili9328paintFilCirc(&lcd0,100,150,40,LCD_COLOR_RED,5,LCD_COLOR_BLUE); ili9328paintFilCirc(&lcd0,120,160,120,LCD_COLOR_RED,1,LCD_COLOR_BLUE); //ili9328paintFilCirc(&lcd0,150,240,80,LCD_COLOR_RED,2,LCD_COLOR_BLUE); + monkDemo(); while(1) { delay_100us(5000); diff --git a/examples/lcdTerminal/lcdTerminal.pro b/examples/lcdTerminal/lcdTerminal.pro new file mode 100644 --- /dev/null +++ b/examples/lcdTerminal/lcdTerminal.pro @@ -0,0 +1,13 @@ +TEMPLATE = app +CONFIG += cpu + + +UCMODEL=stm32f4 + +BSP = STM32F4Eval + +DEFINES += CPUFREQ=160000000 + +SOURCES += \ + main.c + diff --git a/examples/lcdTerminal/main.c b/examples/lcdTerminal/main.c new file mode 100644 --- /dev/null +++ b/examples/lcdTerminal/main.c @@ -0,0 +1,72 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__]; + +#define LCD_COLOR_WHITE 0xFFFF +#define LCD_COLOR_BLACK 0x0000 +#define LCD_COLOR_GREY 0xF7DE +#define LCD_COLOR_BLUE 0x001F +#define LCD_COLOR_BLUE2 0x051F +#define LCD_COLOR_RED 0xF800 +#define LCD_COLOR_MAGENTA 0xF81F +#define LCD_COLOR_GREEN 0x07E0 +#define LCD_COLOR_CYAN 0x7FFF +#define LCD_COLOR_YELLOW 0xFFE0 + +extern int __lineCount__; +extern int __columnCount__; + +int main() +{ + uint16_t innerbuffer[16]; + uint16_t outterbuffer[16]; + for(int i=0;i<16;i++)innerbuffer[i]=LCD_COLOR_BLUE; + for(int i=0;i<16;i++)outterbuffer[i]=LCD_COLOR_RED; + ili9328paintFilRect(&lcd0,0,0,240,320,LCD_COLOR_CYAN,5,LCD_COLOR_BLACK); + + streamdevice* terminal=__opnfiles__[1]; + terminal_init(&lcd0,&ComicSansMS_18,terminal); + //terminal->write(terminal,"Hi",1, 2); + //lcd0.paintText(&lcd0,"Hello",10,50,&ComicSansMS_18,0xFF00); + // __opnfiles__[1]=terminal; + //__opnfiles__[0]=terminal; + int i=1; + //printf("hello World %d",i); + + printf("Line cnt :\n \t%d\n",__lineCount__); + printf("Column cnt :\n \t%d\n",__columnCount__); + printf("CPU Freq :\n \t%dMHz\n",getCpuFreq()/1000000); + while(1) + { + i%=1000; + //terminal->write(&terminal," Hi",1, 2); + //delay_100us(1000); + gpioset(LED1); + //delay_100us(1000); + gpioclr(LED1); + } + printf("hello world\n\r"); + return 0; +} + + + + + + + + + diff --git a/lib/src/common/GRAPHIC/GUI/Widgets/Terminal/Terminal.c b/lib/src/common/GRAPHIC/GUI/Widgets/Terminal/Terminal.c --- a/lib/src/common/GRAPHIC/GUI/Widgets/Terminal/Terminal.c +++ b/lib/src/common/GRAPHIC/GUI/Widgets/Terminal/Terminal.c @@ -0,0 +1,144 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2013, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@gmail.com +-------------------------------------------------------------------------------*/ +#include +#include +#include +#include +#include +#include + +int __line__ =0; +int __column__=0; +int __lineCount__=0; +int __columnCount__=0; +LCD_t* __LCD__=NULL; + +sFONT* __font__; + +int __verticalSpace__=2; +int __horizontalSpace__=0; +int __verticalMargins__=5; +int __horizontalMargins__=5; + +#define CHARXPOS(charwidth) ((__column__*charwidth)+__horizontalMargins__) +#define CHARYPOS(charheight) ((__line__*charheight)+__verticalMargins__+charheight) + +#define charwidth (__font__->Width+__horizontalSpace__) +#define charheight (__font__->Height+__verticalSpace__) + +int terminal_init(LCD_t* LCD,sFONT* font,streamdevice* strdev) +{ + if((LCD!=NULL) && (font!=NULL) && (strdev!=NULL)) + { + __LCD__=LCD; + __font__=font; + __lineCount__ = (LCD->height - (__verticalMargins__*2))/charheight; + __columnCount__ = ((LCD->width - (__horizontalMargins__*2))/charwidth)-1; + + strdev->_stream = (UHANDLE)__LCD__; + strdev->write = (write_t)&terminal_write; + strdev->read = (read_t)&terminal_read; + strdev->setpos = (setpos_t)&terminal_setpos; + strdev->streamPt = 0; + __line__ = 0; + __column__ = 0; + __LCD__->paintFilRect(__LCD__,CHARXPOS(charwidth),CHARYPOS(charheight)-charheight,charwidth,charheight,0x0000,0,0x0000); + return 1; + } + return 0; +} + +void terminal_movecursor(int n) +{ + __column__ += n; + if(__column__>__columnCount__) + { + __line__ += (__column__)/__columnCount__; + __LCD__->paintFilRect(__LCD__,CHARXPOS(charwidth),CHARYPOS(charheight)-charheight,charwidth*(__columnCount__-__column__),charheight,0x0000,0,0x0000); + __line__ = __line__ % __lineCount__; + __column__ = __column__ % __columnCount__; + } + __LCD__->paintFilRect(__LCD__,CHARXPOS(charwidth),CHARYPOS(charheight)-charheight,charwidth,charheight,0x0000,0,0x0000); + +} + +int terminal_writenc(char* data, int n) +{ + int l=0; + char buffer[2]=" "; + while(lpaintFilRect(__LCD__,CHARXPOS(charwidth),CHARYPOS(charheight)-charheight,charwidth,charheight,0x0000,0,0x0000); + __LCD__->paintText(__LCD__,buffer,CHARXPOS(charwidth),CHARYPOS(charheight),__font__,0xFFFF); + terminal_movecursor(1); + } + } + l++; + } + return n; +} + +int terminal_write(streamdeviceptr device,void* data,int size, int n) +{ + return terminal_writenc((char*) data,size*n); +} + +int terminal_read(streamdeviceptr device,void* data,int size, int n) +{ + return n*size; +} + +int terminal_setpos(streamdeviceptr device,int pos) +{ + return 1; +} + +int terminal_close(streamdeviceptr device) +{ + return 1; +} + + + + + + + + + + + + + + diff --git a/lib/src/includes/GRAPHIC/GUI/Widgets/terminal.h b/lib/src/includes/GRAPHIC/GUI/Widgets/terminal.h --- a/lib/src/includes/GRAPHIC/GUI/Widgets/terminal.h +++ b/lib/src/includes/GRAPHIC/GUI/Widgets/terminal.h @@ -21,6 +21,25 @@ -------------------------------------------------------------------------------*/ #ifndef TERMINAL_H #define TERMINAL_H +#include #include +#include +#include +#include + +int terminal_init(LCD_t* LCD,sFONT* font,streamdevice* strdev); +void terminal_movecursor(int n); +int terminal_write(streamdeviceptr device,void* data,int size, int n); +int terminal_read(streamdeviceptr device,void* data,int size, int n); +int terminal_setpos(streamdeviceptr device,int pos); +int terminal_close(streamdeviceptr device); + + + + + + + + #endif diff --git a/lib/src/includes/GRAPHIC/GUI/Widgets/widget.h b/lib/src/includes/GRAPHIC/GUI/Widgets/widget.h --- a/lib/src/includes/GRAPHIC/GUI/Widgets/widget.h +++ b/lib/src/includes/GRAPHIC/GUI/Widgets/widget.h @@ -21,7 +21,7 @@ -------------------------------------------------------------------------------*/ #ifndef WIDGET_H #define WIDGET_H -#include +#include typedef struct widget { diff --git a/lib/src/stm32f4/SDCARD-SDIO/sdcard-sdio.c b/lib/src/stm32f4/SDCARD-SDIO/sdcard-sdio.c new file mode 100644 --- /dev/null +++ b/lib/src/stm32f4/SDCARD-SDIO/sdcard-sdio.c @@ -0,0 +1,121 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2012, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@gmail.com +-------------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void sdcardsdiomake(sdcardDev* sdcard,UHANDLE phy,void (*rcvr_mmc) (UHANDLE,char *,uint32_t ),void (*xmit_mmc) (UHANDLE,const char *,uint32_t ),void (*setspeed) (UHANDLE phy,uint32_t speed),uint32_t (*getspeed) (UHANDLE phy)) +{ + sdcard->phy = phy; + sdcard->rcvr_mmc = rcvr_mmc; + sdcard->xmit_mmc = xmit_mmc; + sdcard->setspeed = setspeed; + sdcard->getspeed = getspeed; +} + +void sdcardsdiomakeblkdev(blkdevice* dev,sdcardDev* sdcard, blkdevselect_t select,blkdevpower_t power,blkdevdetect_t detect,blkdevwriteprotected_t writeprotected) +{ + dev->phy=sdcard; + dev->select=select; + dev->power = power; + dev->detect = detect; + dev->writeprotected = writeprotected; + /*dev->write = sdcarddisk_write; + dev->read = sdcarddisk_read; + dev->ioctl = sdcarddisk_ioctl; + dev->initialize = sdcarddisk_initialize; + dev->status = sdcarddisk_status;*/ +} + +int sdcardselect (blkdeviceptr _this) +{ + +} + +void sdcarddeselect (blkdeviceptr _this) +{ + +} + +int sdcardwait_ready (sdcardDev* sdcard) +{ + +} + +int sdcardxmit_datablock (sdcardDev* sdcard,const char *buff,char token) +{ + +} + +int sdcardrcvr_datablock (sdcardDev* sdcard,char *buff,uint32_t btr) +{ + +} + +char sdcardsend_cmd (blkdeviceptr _this,char cmd,uint32_t arg) +{ + +} + +DSTATUS sdcarddisk_status (blkdeviceptr _this) +{ + return RES_OK; +} + +DSTATUS sdcarddisk_initialize (blkdeviceptr _this) +{ + return RES_OK; +} + +DRESULT sdcarddisk_read (blkdeviceptr _this,char *buff,uint32_t sector,char count) +{ + return RES_OK; +} + +DRESULT sdcarddisk_write (blkdeviceptr _this,const char *buff,uint32_t sector,char count) +{ + +} + +DRESULT sdcarddisk_ioctl (blkdeviceptr _this,char ctrl,void *buff) +{ + return RES_OK; +} + + + + + + + + + + + + diff --git a/lib/src/stm32f4/SDCARD-SDIO/sdcard-sdio.pro b/lib/src/stm32f4/SDCARD-SDIO/sdcard-sdio.pro new file mode 100644 --- /dev/null +++ b/lib/src/stm32f4/SDCARD-SDIO/sdcard-sdio.pro @@ -0,0 +1,16 @@ +TEMPLATE = lib +OBJECTS_DIR = obj + +SOURCES += sdcard-sdio.c + +INCLUDEPATH += ../../includes \ + ../CPU/STM32F4xx_StdPeriph_Driver/inc \ + ../CPU/CMSIS/Include + + +UCMODEL=stm32f4 + +target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL +INSTALLS += target + +