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 haofan Zheng

Committer:
hazheng
Date:
Thu Mar 30 22:34:20 2017 +0000
Revision:
46:a5eb9bd3bb55
Parent:
44:15de535c4005
Child:
92:e9bd429f16b5
Changed more code into pure C style. Finished driving complete circle! Both screen and camera works fine!

Who changed what in which revision?

UserRevisionLine numberNew 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 46:a5eb9bd3bb55 30
hazheng 46:a5eb9bd3bb55 31
hazheng 46:a5eb9bd3bb55 32 #ifdef __cplusplus
hazheng 46:a5eb9bd3bb55 33 extern "C" {
hazheng 46:a5eb9bd3bb55 34 #endif
hazheng 46:a5eb9bd3bb55 35
hazheng 40:be98219930e4 36 void ardu_utft_init(); //We only use LANDSCAPE orientation!
hazheng 40:be98219930e4 37
hazheng 40:be98219930e4 38 void ardu_cam_set_mode(uint8_t mode);
hazheng 40:be98219930e4 39
hazheng 41:7b21c5e3599e 40 void ardu_utft_write_DATA(uint8_t VH, uint8_t VL);
hazheng 41:7b21c5e3599e 41
hazheng 40:be98219930e4 42 void ardu_utft_clr_scr();
hazheng 40:be98219930e4 43
hazheng 40:be98219930e4 44 void ardu_utft_set_xy(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
hazheng 40:be98219930e4 45
hazheng 40:be98219930e4 46 void ardu_utft_reset_xy();
hazheng 40:be98219930e4 47
hazheng 40:be98219930e4 48 void ardu_utft_set_color(uint8_t r, uint8_t g, uint8_t b);
hazheng 40:be98219930e4 49
hazheng 40:be98219930e4 50 void ardu_utft_draw_rect(int x1, int y1, int x2, int y2);
hazheng 40:be98219930e4 51
hazheng 40:be98219930e4 52 void ardu_utft_draw_hline(int x, int y, int l);
hazheng 40:be98219930e4 53
hazheng 40:be98219930e4 54 void ardu_utft_draw_vline(int x, int y, int l);
hazheng 40:be98219930e4 55
hazheng 42:c4e1606087ff 56 void ardu_utft_draw_pixel(int x, int y);
hazheng 42:c4e1606087ff 57
hazheng 42:c4e1606087ff 58 void ardu_utft_fill_rect(int x1, int y1, int x2, int y2);
hazheng 42:c4e1606087ff 59
hazheng 42:c4e1606087ff 60 void ardu_utft_set_font(uint8_t * font);
hazheng 42:c4e1606087ff 61
hazheng 42:c4e1606087ff 62 void ardu_utft_print_char(char c, int x, int y);
hazheng 42:c4e1606087ff 63
hazheng 42:c4e1606087ff 64 void ardu_utft_print(char * st, int x, int y);
hazheng 40:be98219930e4 65
hazheng 44:15de535c4005 66 inline void ardu_utft_set_camimg_row(const uint16_t row)
hazheng 44:15de535c4005 67 {
hazheng 44:15de535c4005 68 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 69 }
hazheng 44:15de535c4005 70
hazheng 44:15de535c4005 71 inline void ardu_utft_set_camimg_rowcol(const uint16_t row, const uint16_t col)
hazheng 44:15de535c4005 72 {
hazheng 44:15de535c4005 73 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 74 }
hazheng 44:15de535c4005 75
hazheng 46:a5eb9bd3bb55 76 #ifdef __cplusplus
hazheng 46:a5eb9bd3bb55 77 }
hazheng 46:a5eb9bd3bb55 78 #endif
hazheng 46:a5eb9bd3bb55 79
hazheng 40:be98219930e4 80 #endif //ARDU_UTFT_H