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

Hardwares/ArduUTFT.h

Committer:
hazheng
Date:
2017-03-30
Revision:
46:a5eb9bd3bb55
Parent:
44:15de535c4005
Child:
92:e9bd429f16b5

File content as of revision 46:a5eb9bd3bb55:

#pragma once
#ifndef ARDU_UTFT_H
#define ARDU_UTFT_H

#include <mbed.h>
#include "PinAssignment.h"

#define ARDUCHIP_MODE           0x02  //Mode register
//#define MCU2LCD_MODE            0x00
//#define CAM2LCD_MODE            0x01
#define MCU2LCD_MODE            0x01
#define CAM2LCD_MODE            0x02
//#define LCD2MCU_MODE            0x04

#define ARDUCHIP_TEST1_UTFT          0x00  //TEST register
#define ARDUCHIP_TEST_MSG_UTFT       0x72

#define ARDUCHIP_VER_NUM_UTFT        0x61


#define UTFT_DISP_X_SIZE  239
#define UTFT_DISP_Y_SIZE  319

#define UTFT_LEFT 0
#define UTFT_RIGHT 9999
#define UTFT_CENTER 9998

#define CAM_IMG_CANVAS_ROW_OFFSET 20
#define CAM_IMG_CANVAS_COL_OFFSET 300


#ifdef __cplusplus
extern "C" {
#endif

void ardu_utft_init(); //We only use LANDSCAPE orientation!

void ardu_cam_set_mode(uint8_t mode);

void ardu_utft_write_DATA(uint8_t VH, uint8_t VL);

void ardu_utft_clr_scr();

void ardu_utft_set_xy(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);

void ardu_utft_reset_xy();

void ardu_utft_set_color(uint8_t r, uint8_t g, uint8_t b);

void ardu_utft_draw_rect(int x1, int y1, int x2, int y2);

void ardu_utft_draw_hline(int x, int y, int l);

void ardu_utft_draw_vline(int x, int y, int l);

void ardu_utft_draw_pixel(int x, int y);

void ardu_utft_fill_rect(int x1, int y1, int x2, int y2);

void ardu_utft_set_font(uint8_t * font);

void ardu_utft_print_char(char c, int x, int y);

void ardu_utft_print(char * st, int x, int y);

inline void ardu_utft_set_camimg_row(const uint16_t row)
{
    ardu_utft_set_xy(0, row + CAM_IMG_CANVAS_ROW_OFFSET, CAM_IMG_CANVAS_COL_OFFSET, row + CAM_IMG_CANVAS_ROW_OFFSET);
}

inline void ardu_utft_set_camimg_rowcol(const uint16_t row, const uint16_t col)
{
    ardu_utft_set_xy(0, row + CAM_IMG_CANVAS_ROW_OFFSET, CAM_IMG_CANVAS_COL_OFFSET - col, row + CAM_IMG_CANVAS_ROW_OFFSET);
}

#ifdef __cplusplus
}
#endif

#endif //ARDU_UTFT_H