STM32F429I-DISCO Template w/ stdout redirection to display
Dependencies: LCD_DISCO_F429ZI LCD_LOG_DISCO TS_DISCO_F429ZI mbed-dev
Status
- Just working
Planned features
- Redirect stderr with color change
- rewrite entire lcd_log to C++
main.cpp@4:8188d5640a90, 2015-12-26 (annotated)
- Committer:
- icis4
- Date:
- Sat Dec 26 09:53:29 2015 +0000
- Revision:
- 4:8188d5640a90
- Parent:
- 3:79e2d3d36b63
- Child:
- 5:8ed13d45a9ce
License update
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
icis4 | 4:8188d5640a90 | 1 | /* Copyright (c) 2015 Ivaylo Iltchev www.iltchev.com, MIT License |
icis4 | 4:8188d5640a90 | 2 | * |
icis4 | 4:8188d5640a90 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
icis4 | 4:8188d5640a90 | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
icis4 | 4:8188d5640a90 | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
icis4 | 4:8188d5640a90 | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
icis4 | 4:8188d5640a90 | 7 | * Software is furnished to do so, subject to the following conditions: |
icis4 | 4:8188d5640a90 | 8 | * |
icis4 | 4:8188d5640a90 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
icis4 | 4:8188d5640a90 | 10 | * substantial portions of the Software. |
icis4 | 4:8188d5640a90 | 11 | * |
icis4 | 4:8188d5640a90 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
icis4 | 4:8188d5640a90 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
icis4 | 4:8188d5640a90 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
icis4 | 4:8188d5640a90 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
icis4 | 4:8188d5640a90 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
icis4 | 4:8188d5640a90 | 17 | */ |
icis4 | 4:8188d5640a90 | 18 | |
icis4 | 0:355a7d27c2f6 | 19 | #include "mbed.h" |
icis4 | 0:355a7d27c2f6 | 20 | #include <stdio.h> |
icis4 | 0:355a7d27c2f6 | 21 | #include "TS_DISCO_F429ZI.h" |
icis4 | 0:355a7d27c2f6 | 22 | #include "LCD_DISCO_F429ZI.h" |
icis4 | 0:355a7d27c2f6 | 23 | #include "LCD_LOG_DISCO.h" |
icis4 | 0:355a7d27c2f6 | 24 | |
icis4 | 0:355a7d27c2f6 | 25 | LCD_DISCO_F429ZI lcd; |
icis4 | 0:355a7d27c2f6 | 26 | TS_DISCO_F429ZI ts; |
icis4 | 0:355a7d27c2f6 | 27 | LCDLog lcdlog("lcdlog"); |
icis4 | 0:355a7d27c2f6 | 28 | |
icis4 | 0:355a7d27c2f6 | 29 | extern "C" { |
icis4 | 0:355a7d27c2f6 | 30 | int LCD_LOG_write(uint8_t* text); |
icis4 | 0:355a7d27c2f6 | 31 | } |
icis4 | 0:355a7d27c2f6 | 32 | |
icis4 | 0:355a7d27c2f6 | 33 | int main() |
icis4 | 0:355a7d27c2f6 | 34 | { |
icis4 | 0:355a7d27c2f6 | 35 | TS_StateTypeDef TS_State; |
icis4 | 0:355a7d27c2f6 | 36 | uint16_t x, y; |
icis4 | 0:355a7d27c2f6 | 37 | uint8_t status; |
icis4 | 0:355a7d27c2f6 | 38 | |
icis4 | 0:355a7d27c2f6 | 39 | lcdlog.Init(stdout, "TOUCHSCREEN DEMO"); |
icis4 | 0:355a7d27c2f6 | 40 | |
icis4 | 0:355a7d27c2f6 | 41 | status = ts.Init(lcd.GetXSize(), lcd.GetYSize()); |
icis4 | 0:355a7d27c2f6 | 42 | if (status != TS_OK) |
icis4 | 0:355a7d27c2f6 | 43 | { |
icis4 | 0:355a7d27c2f6 | 44 | lcdlog.Footer("INIT FAIL\n"); |
icis4 | 0:355a7d27c2f6 | 45 | } else { |
icis4 | 0:355a7d27c2f6 | 46 | lcdlog.Footer("INIT OK"); |
icis4 | 0:355a7d27c2f6 | 47 | } |
icis4 | 0:355a7d27c2f6 | 48 | |
icis4 | 0:355a7d27c2f6 | 49 | printf("** Start **\n"); |
icis4 | 0:355a7d27c2f6 | 50 | x = TS_State.X; |
icis4 | 0:355a7d27c2f6 | 51 | y = TS_State.Y; |
icis4 | 0:355a7d27c2f6 | 52 | while(1) |
icis4 | 0:355a7d27c2f6 | 53 | { |
icis4 | 0:355a7d27c2f6 | 54 | ts.GetState(&TS_State); |
icis4 | 0:355a7d27c2f6 | 55 | if (TS_State.TouchDetected) |
icis4 | 0:355a7d27c2f6 | 56 | { |
icis4 | 0:355a7d27c2f6 | 57 | if (x != TS_State.X || y != TS_State.Y) { |
icis4 | 0:355a7d27c2f6 | 58 | printf("x=%03d y=%03d\n", x, y); |
icis4 | 0:355a7d27c2f6 | 59 | x = TS_State.X; |
icis4 | 0:355a7d27c2f6 | 60 | y = TS_State.Y; |
icis4 | 0:355a7d27c2f6 | 61 | } |
icis4 | 0:355a7d27c2f6 | 62 | } |
icis4 | 0:355a7d27c2f6 | 63 | wait_ms(5); |
icis4 | 0:355a7d27c2f6 | 64 | } |
icis4 | 0:355a7d27c2f6 | 65 | } |
icis4 | 0:355a7d27c2f6 | 66 |