##// END OF EJS Templates
Added graphical terminal (first shot).
jeandet -
r50:144bdeadc77a dev_alexis
parent child
Show More
@@ -0,0 +1,13
1 TEMPLATE = app
2 CONFIG += cpu
3
4
5 UCMODEL=stm32f4
6
7 BSP = STM32F4Eval
8
9 DEFINES += CPUFREQ=160000000
10
11 SOURCES += \
12 main.c
13
@@ -0,0 +1,72
1 #include <stdio.h>
2 #include <fat32.h>
3 #include <gpio.h>
4 #include <uart.h>
5 #include <stm32f4xx.h>
6 #include <math.h>
7 #include <bsp.h>
8 #include <i2c.h>
9 #include <CS43L22.h>
10 #include <ina226.h>
11 #include <fonts.h>
12 #include <stdlib.h>
13 #include <core.h>
14 #include <terminal.h>
15
16 extern streamdevice* __opnfiles__[__MAX_OPENED_FILES__];
17
18 #define LCD_COLOR_WHITE 0xFFFF
19 #define LCD_COLOR_BLACK 0x0000
20 #define LCD_COLOR_GREY 0xF7DE
21 #define LCD_COLOR_BLUE 0x001F
22 #define LCD_COLOR_BLUE2 0x051F
23 #define LCD_COLOR_RED 0xF800
24 #define LCD_COLOR_MAGENTA 0xF81F
25 #define LCD_COLOR_GREEN 0x07E0
26 #define LCD_COLOR_CYAN 0x7FFF
27 #define LCD_COLOR_YELLOW 0xFFE0
28
29 extern int __lineCount__;
30 extern int __columnCount__;
31
32 int main()
33 {
34 uint16_t innerbuffer[16];
35 uint16_t outterbuffer[16];
36 for(int i=0;i<16;i++)innerbuffer[i]=LCD_COLOR_BLUE;
37 for(int i=0;i<16;i++)outterbuffer[i]=LCD_COLOR_RED;
38 ili9328paintFilRect(&lcd0,0,0,240,320,LCD_COLOR_CYAN,5,LCD_COLOR_BLACK);
39
40 streamdevice* terminal=__opnfiles__[1];
41 terminal_init(&lcd0,&ComicSansMS_18,terminal);
42 //terminal->write(terminal,"Hi",1, 2);
43 //lcd0.paintText(&lcd0,"Hello",10,50,&ComicSansMS_18,0xFF00);
44 // __opnfiles__[1]=terminal;
45 //__opnfiles__[0]=terminal;
46 int i=1;
47 //printf("hello World %d",i);
48
49 printf("Line cnt :\n \t%d\n",__lineCount__);
50 printf("Column cnt :\n \t%d\n",__columnCount__);
51 printf("CPU Freq :\n \t%dMHz\n",getCpuFreq()/1000000);
52 while(1)
53 {
54 i%=1000;
55 //terminal->write(&terminal," Hi",1, 2);
56 //delay_100us(1000);
57 gpioset(LED1);
58 //delay_100us(1000);
59 gpioclr(LED1);
60 }
61 printf("hello world\n\r");
62 return 0;
63 }
64
65
66
67
68
69
70
71
72
@@ -0,0 +1,121
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the libuc, microcontroler library
3 -- Copyright (C) 2012, Alexis Jeandet
4 --
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------
19 -- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@gmail.com
21 -------------------------------------------------------------------------------*/
22
23 #include <i2c.h>
24 #include <stm32f4xx_usart.h>
25 #include <stm32f4xx_rcc.h>
26 #include <stm32f4xx_gpio.h>
27 #include <stm32f4xx_sdio.h>
28 #include <gpio.h>
29 #include <core.h>
30 #include <sdcard.h>
31 #include <sdcard-sdio.h>
32
33 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))
34 {
35 sdcard->phy = phy;
36 sdcard->rcvr_mmc = rcvr_mmc;
37 sdcard->xmit_mmc = xmit_mmc;
38 sdcard->setspeed = setspeed;
39 sdcard->getspeed = getspeed;
40 }
41
42 void sdcardsdiomakeblkdev(blkdevice* dev,sdcardDev* sdcard, blkdevselect_t select,blkdevpower_t power,blkdevdetect_t detect,blkdevwriteprotected_t writeprotected)
43 {
44 dev->phy=sdcard;
45 dev->select=select;
46 dev->power = power;
47 dev->detect = detect;
48 dev->writeprotected = writeprotected;
49 /*dev->write = sdcarddisk_write;
50 dev->read = sdcarddisk_read;
51 dev->ioctl = sdcarddisk_ioctl;
52 dev->initialize = sdcarddisk_initialize;
53 dev->status = sdcarddisk_status;*/
54 }
55
56 int sdcardselect (blkdeviceptr _this)
57 {
58
59 }
60
61 void sdcarddeselect (blkdeviceptr _this)
62 {
63
64 }
65
66 int sdcardwait_ready (sdcardDev* sdcard)
67 {
68
69 }
70
71 int sdcardxmit_datablock (sdcardDev* sdcard,const char *buff,char token)
72 {
73
74 }
75
76 int sdcardrcvr_datablock (sdcardDev* sdcard,char *buff,uint32_t btr)
77 {
78
79 }
80
81 char sdcardsend_cmd (blkdeviceptr _this,char cmd,uint32_t arg)
82 {
83
84 }
85
86 DSTATUS sdcarddisk_status (blkdeviceptr _this)
87 {
88 return RES_OK;
89 }
90
91 DSTATUS sdcarddisk_initialize (blkdeviceptr _this)
92 {
93 return RES_OK;
94 }
95
96 DRESULT sdcarddisk_read (blkdeviceptr _this,char *buff,uint32_t sector,char count)
97 {
98 return RES_OK;
99 }
100
101 DRESULT sdcarddisk_write (blkdeviceptr _this,const char *buff,uint32_t sector,char count)
102 {
103
104 }
105
106 DRESULT sdcarddisk_ioctl (blkdeviceptr _this,char ctrl,void *buff)
107 {
108 return RES_OK;
109 }
110
111
112
113
114
115
116
117
118
119
120
121
@@ -0,0 +1,16
1 TEMPLATE = lib
2 OBJECTS_DIR = obj
3
4 SOURCES += sdcard-sdio.c
5
6 INCLUDEPATH += ../../includes \
7 ../CPU/STM32F4xx_StdPeriph_Driver/inc \
8 ../CPU/CMSIS/Include
9
10
11 UCMODEL=stm32f4
12
13 target.path = $$[QT_INSTALL_LIBS]/$$UCMODEL
14 INSTALLS += target
15
16
@@ -6,7 +6,8 SUBDIRS += QtTest/test.pro \
6 STM32F4IT \
6 STM32F4IT \
7 M4StickV2 \
7 M4StickV2 \
8 lcdHello \
8 lcdHello \
9 BeagleSynthHello
9 BeagleSynthHello \
10 lcdTerminal
10
11
11
12
12
13
@@ -11,7 +11,7
11 #include <fonts.h>
11 #include <fonts.h>
12 #include <stdlib.h>
12 #include <stdlib.h>
13 #include <core.h>
13 #include <core.h>
14
14 #include <terminal.h>
15
15
16 extern streamdevice* __opnfiles__[];
16 extern streamdevice* __opnfiles__[];
17
17
@@ -69,6 +69,7 int main()
69 ili9328paintFilCirc(&lcd0,100,150,40,LCD_COLOR_RED,5,LCD_COLOR_BLUE);
69 ili9328paintFilCirc(&lcd0,100,150,40,LCD_COLOR_RED,5,LCD_COLOR_BLUE);
70 ili9328paintFilCirc(&lcd0,120,160,120,LCD_COLOR_RED,1,LCD_COLOR_BLUE);
70 ili9328paintFilCirc(&lcd0,120,160,120,LCD_COLOR_RED,1,LCD_COLOR_BLUE);
71 //ili9328paintFilCirc(&lcd0,150,240,80,LCD_COLOR_RED,2,LCD_COLOR_BLUE);
71 //ili9328paintFilCirc(&lcd0,150,240,80,LCD_COLOR_RED,2,LCD_COLOR_BLUE);
72 monkDemo();
72 while(1)
73 while(1)
73 {
74 {
74 delay_100us(5000);
75 delay_100us(5000);
@@ -0,0 +1,144
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the libuc, microcontroler library
3 -- Copyright (C) 2013, Alexis Jeandet
4 --
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
9 --
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14 --
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------
19 -- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@gmail.com
21 -------------------------------------------------------------------------------*/
22 #include <widget.h>
23 #include <terminal.h>
24 #include <stdint.h>
25 #include <stdio.h>
26 #include <gpio.h>
27 #include <core.h>
28
29 int __line__ =0;
30 int __column__=0;
31 int __lineCount__=0;
32 int __columnCount__=0;
33 LCD_t* __LCD__=NULL;
34
35 sFONT* __font__;
36
37 int __verticalSpace__=2;
38 int __horizontalSpace__=0;
39 int __verticalMargins__=5;
40 int __horizontalMargins__=5;
41
42 #define CHARXPOS(charwidth) ((__column__*charwidth)+__horizontalMargins__)
43 #define CHARYPOS(charheight) ((__line__*charheight)+__verticalMargins__+charheight)
44
45 #define charwidth (__font__->Width+__horizontalSpace__)
46 #define charheight (__font__->Height+__verticalSpace__)
47
48 int terminal_init(LCD_t* LCD,sFONT* font,streamdevice* strdev)
49 {
50 if((LCD!=NULL) && (font!=NULL) && (strdev!=NULL))
51 {
52 __LCD__=LCD;
53 __font__=font;
54 __lineCount__ = (LCD->height - (__verticalMargins__*2))/charheight;
55 __columnCount__ = ((LCD->width - (__horizontalMargins__*2))/charwidth)-1;
56
57 strdev->_stream = (UHANDLE)__LCD__;
58 strdev->write = (write_t)&terminal_write;
59 strdev->read = (read_t)&terminal_read;
60 strdev->setpos = (setpos_t)&terminal_setpos;
61 strdev->streamPt = 0;
62 __line__ = 0;
63 __column__ = 0;
64 __LCD__->paintFilRect(__LCD__,CHARXPOS(charwidth),CHARYPOS(charheight)-charheight,charwidth,charheight,0x0000,0,0x0000);
65 return 1;
66 }
67 return 0;
68 }
69
70 void terminal_movecursor(int n)
71 {
72 __column__ += n;
73 if(__column__>__columnCount__)
74 {
75 __line__ += (__column__)/__columnCount__;
76 __LCD__->paintFilRect(__LCD__,CHARXPOS(charwidth),CHARYPOS(charheight)-charheight,charwidth*(__columnCount__-__column__),charheight,0x0000,0,0x0000);
77 __line__ = __line__ % __lineCount__;
78 __column__ = __column__ % __columnCount__;
79 }
80 __LCD__->paintFilRect(__LCD__,CHARXPOS(charwidth),CHARYPOS(charheight)-charheight,charwidth,charheight,0x0000,0,0x0000);
81
82 }
83
84 int terminal_writenc(char* data, int n)
85 {
86 int l=0;
87 char buffer[2]=" ";
88 while(l<n)
89 {
90
91 buffer[0]=data[l];
92 if(buffer[0]=='\n')
93 {
94 __line__= (__line__+1) % __lineCount__;
95 __column__ = 0;
96 }else {
97 if(buffer[0]=='\t')
98 {
99 __line__ += (__column__+3) / __columnCount__;
100 __column__= (__column__+3) % __columnCount__;
101 }else {
102 __LCD__->paintFilRect(__LCD__,CHARXPOS(charwidth),CHARYPOS(charheight)-charheight,charwidth,charheight,0x0000,0,0x0000);
103 __LCD__->paintText(__LCD__,buffer,CHARXPOS(charwidth),CHARYPOS(charheight),__font__,0xFFFF);
104 terminal_movecursor(1);
105 }
106 }
107 l++;
108 }
109 return n;
110 }
111
112 int terminal_write(streamdeviceptr device,void* data,int size, int n)
113 {
114 return terminal_writenc((char*) data,size*n);
115 }
116
117 int terminal_read(streamdeviceptr device,void* data,int size, int n)
118 {
119 return n*size;
120 }
121
122 int terminal_setpos(streamdeviceptr device,int pos)
123 {
124 return 1;
125 }
126
127 int terminal_close(streamdeviceptr device)
128 {
129 return 1;
130 }
131
132
133
134
135
136
137
138
139
140
141
142
143
144
@@ -21,6 +21,25
21 -------------------------------------------------------------------------------*/
21 -------------------------------------------------------------------------------*/
22 #ifndef TERMINAL_H
22 #ifndef TERMINAL_H
23 #define TERMINAL_H
23 #define TERMINAL_H
24 #include <stdint.h>
24 #include <widget.h>
25 #include <widget.h>
26 #include <streamdevices.h>
27 #include <genericLCD_Controler.h>
28 #include <fonts.h>
29
30 int terminal_init(LCD_t* LCD,sFONT* font,streamdevice* strdev);
31 void terminal_movecursor(int n);
32 int terminal_write(streamdeviceptr device,void* data,int size, int n);
33 int terminal_read(streamdeviceptr device,void* data,int size, int n);
34 int terminal_setpos(streamdeviceptr device,int pos);
35 int terminal_close(streamdeviceptr device);
36
37
38
39
40
41
42
43
25
44
26 #endif
45 #endif
@@ -21,7 +21,7
21 -------------------------------------------------------------------------------*/
21 -------------------------------------------------------------------------------*/
22 #ifndef WIDGET_H
22 #ifndef WIDGET_H
23 #define WIDGET_H
23 #define WIDGET_H
24 #include <widget.h>
24 #include <stdint.h>
25
25
26 typedef struct widget
26 typedef struct widget
27 {
27 {
General Comments 0
You need to be logged in to leave comments. Login now