SmartWheels self-driving race car. Designed for NXP Cup. Uses FRDM-KL25Z, area-scan camera, and simple image processing to detect and navigate any NXP spec track.
Dependencies: TSI USBDevice mbed-dev
Fork of SmartWheels by
Hardwares/ArduUTFT.h@44:15de535c4005, 2017-03-29 (annotated)
- Committer:
- hazheng
- Date:
- Wed Mar 29 21:19:27 2017 +0000
- Revision:
- 44:15de535c4005
- Parent:
- 42:c4e1606087ff
- Child:
- 46:a5eb9bd3bb55
Made the car move!...
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hazheng | 40:be98219930e4 | 1 | #pragma once |
hazheng | 40:be98219930e4 | 2 | #ifndef ARDU_UTFT_H |
hazheng | 40:be98219930e4 | 3 | #define ARDU_UTFT_H |
hazheng | 40:be98219930e4 | 4 | |
hazheng | 40:be98219930e4 | 5 | #include <mbed.h> |
hazheng | 40:be98219930e4 | 6 | #include "PinAssignment.h" |
hazheng | 40:be98219930e4 | 7 | |
hazheng | 40:be98219930e4 | 8 | #define ARDUCHIP_MODE 0x02 //Mode register |
hazheng | 40:be98219930e4 | 9 | //#define MCU2LCD_MODE 0x00 |
hazheng | 40:be98219930e4 | 10 | //#define CAM2LCD_MODE 0x01 |
hazheng | 40:be98219930e4 | 11 | #define MCU2LCD_MODE 0x01 |
hazheng | 40:be98219930e4 | 12 | #define CAM2LCD_MODE 0x02 |
hazheng | 40:be98219930e4 | 13 | //#define LCD2MCU_MODE 0x04 |
hazheng | 40:be98219930e4 | 14 | |
hazheng | 40:be98219930e4 | 15 | #define ARDUCHIP_TEST1_UTFT 0x00 //TEST register |
hazheng | 40:be98219930e4 | 16 | #define ARDUCHIP_TEST_MSG_UTFT 0x72 |
hazheng | 40:be98219930e4 | 17 | |
hazheng | 40:be98219930e4 | 18 | #define ARDUCHIP_VER_NUM_UTFT 0x61 |
hazheng | 42:c4e1606087ff | 19 | |
hazheng | 42:c4e1606087ff | 20 | |
hazheng | 42:c4e1606087ff | 21 | #define UTFT_DISP_X_SIZE 239 |
hazheng | 42:c4e1606087ff | 22 | #define UTFT_DISP_Y_SIZE 319 |
hazheng | 42:c4e1606087ff | 23 | |
hazheng | 42:c4e1606087ff | 24 | #define UTFT_LEFT 0 |
hazheng | 42:c4e1606087ff | 25 | #define UTFT_RIGHT 9999 |
hazheng | 42:c4e1606087ff | 26 | #define UTFT_CENTER 9998 |
hazheng | 44:15de535c4005 | 27 | |
hazheng | 44:15de535c4005 | 28 | #define CAM_IMG_CANVAS_ROW_OFFSET 20 |
hazheng | 44:15de535c4005 | 29 | #define CAM_IMG_CANVAS_COL_OFFSET 300 |
hazheng | 40:be98219930e4 | 30 | |
hazheng | 40:be98219930e4 | 31 | void ardu_utft_init(); //We only use LANDSCAPE orientation! |
hazheng | 40:be98219930e4 | 32 | |
hazheng | 40:be98219930e4 | 33 | void ardu_cam_set_mode(uint8_t mode); |
hazheng | 40:be98219930e4 | 34 | |
hazheng | 41:7b21c5e3599e | 35 | void ardu_utft_write_DATA(uint8_t VH, uint8_t VL); |
hazheng | 41:7b21c5e3599e | 36 | |
hazheng | 40:be98219930e4 | 37 | void ardu_utft_clr_scr(); |
hazheng | 40:be98219930e4 | 38 | |
hazheng | 40:be98219930e4 | 39 | void ardu_utft_set_xy(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2); |
hazheng | 40:be98219930e4 | 40 | |
hazheng | 40:be98219930e4 | 41 | void ardu_utft_reset_xy(); |
hazheng | 40:be98219930e4 | 42 | |
hazheng | 40:be98219930e4 | 43 | void ardu_utft_set_color(uint8_t r, uint8_t g, uint8_t b); |
hazheng | 40:be98219930e4 | 44 | |
hazheng | 40:be98219930e4 | 45 | void ardu_utft_draw_rect(int x1, int y1, int x2, int y2); |
hazheng | 40:be98219930e4 | 46 | |
hazheng | 40:be98219930e4 | 47 | void ardu_utft_draw_hline(int x, int y, int l); |
hazheng | 40:be98219930e4 | 48 | |
hazheng | 40:be98219930e4 | 49 | void ardu_utft_draw_vline(int x, int y, int l); |
hazheng | 40:be98219930e4 | 50 | |
hazheng | 42:c4e1606087ff | 51 | void ardu_utft_draw_pixel(int x, int y); |
hazheng | 42:c4e1606087ff | 52 | |
hazheng | 42:c4e1606087ff | 53 | void ardu_utft_fill_rect(int x1, int y1, int x2, int y2); |
hazheng | 42:c4e1606087ff | 54 | |
hazheng | 42:c4e1606087ff | 55 | void ardu_utft_set_font(uint8_t * font); |
hazheng | 42:c4e1606087ff | 56 | |
hazheng | 42:c4e1606087ff | 57 | void ardu_utft_print_char(char c, int x, int y); |
hazheng | 42:c4e1606087ff | 58 | |
hazheng | 42:c4e1606087ff | 59 | void ardu_utft_print(char * st, int x, int y); |
hazheng | 40:be98219930e4 | 60 | |
hazheng | 44:15de535c4005 | 61 | inline void ardu_utft_set_camimg_row(const uint16_t row) |
hazheng | 44:15de535c4005 | 62 | { |
hazheng | 44:15de535c4005 | 63 | ardu_utft_set_xy(0, row + CAM_IMG_CANVAS_ROW_OFFSET, CAM_IMG_CANVAS_COL_OFFSET, row + CAM_IMG_CANVAS_ROW_OFFSET); |
hazheng | 44:15de535c4005 | 64 | } |
hazheng | 44:15de535c4005 | 65 | |
hazheng | 44:15de535c4005 | 66 | inline void ardu_utft_set_camimg_rowcol(const uint16_t row, const uint16_t col) |
hazheng | 44:15de535c4005 | 67 | { |
hazheng | 44:15de535c4005 | 68 | ardu_utft_set_xy(0, row + CAM_IMG_CANVAS_ROW_OFFSET, CAM_IMG_CANVAS_COL_OFFSET - col, row + CAM_IMG_CANVAS_ROW_OFFSET); |
hazheng | 44:15de535c4005 | 69 | } |
hazheng | 44:15de535c4005 | 70 | |
hazheng | 40:be98219930e4 | 71 | #endif //ARDU_UTFT_H |