Listing 1. Global Variables, Constants, and Objects
// Set up Picadillo display hardware.
analogWrite(PIN_BACKLIGHT, 255);
tft.initializeDevice();
tft.setRotation(0);
tft.fillScreen(Color::Black);
tft.setFont(Fonts::Topaz);
tft.setTextColor(Color::White, Color::Black);
printCentered(50, "uCAM II 128x128 RGB565 image");
printCentered(70, "Camera Operation Demonstration");
// Picadill and 4D Systems uCAM II demo.
//
// DLC 3/2015
#include <UTFT.h>
with the uCAM-II command arrays
that we might use. This is the same
as I used in the MAX32 demo
program.
#include <DSPI.h>
#include <TFT.h>
In a typical sketch, the setup()
function sets everything up that we
will be using in the main loop. Listing
2 is the setup for the Picadillo display.
// Configure the display
PICadillo35t tft;
// camera screen "pages"
uint16_t pg1[16384];
// Misc.
uint8_t junk;
// changing bytes into words for graphics
union {
uint16_t word;
uint8_t byte[2];
} convert;
Listing 3 shows the protocol for
waking the camera up and getting it
ready. Once the uCAM-II is awake, it
will only remain awake for 15 seconds
if nothing is talking to it. We will be
streaming data as fast as we can
from it, so it isn’t going to go to sleep
on us! This is exactly the same as I
used with the MAX32 program in the
April issue.
Once again, we will use COM1
Tx/Rx to talk to the camera board.
// Command and status arrays
uint8_t cmd[6];
uint8_t status[6];
uint8_t status2[6];
This sequence is laid out in a flow
chart in the uCAM-II documentation.
// Commands
uint8_t INIT[6] = {0xAA,0x01,0x00,0x06,0x09,0x00};
// 16bit 565RGB color raw format
uint8_t GETPIC[6] = {0xAA,0x04,0x02,0x00,0x00,0x00};
// GET PICTURE Raw picture mode
uint8_t RESET[6] = {0xAA,0x08,0x01,0x00,0x00,0x00};
// RESET state machines only
uint8_t HRESET[6] = {0xAA,0x08,0x01,0x00,0x00,0xFF};
// RESET whole camera
uint8_t SYNC[6] = {0xAA,0x0D,0x00,0x00,0x00,0x00};
// wake the camera up
uint8_t ACKF[6] = {0xAA,0x0E,0x0A,0x00,0x00,0x00};
// ACK a complete frame received
uint8_t ACKS[6] = {0xAA,0x0E,0x0D,0x00,0x00,0x00};
// ACK the SYNC response
uint8_t BAUD[6] = {0xAA,0x07,0x02,0x00,0x00,0x00};
// Set BAUD to 1228800
The Picadillo is a 32-bit microcontroller
running at 80 MHz, so it can easily
out-pace this serial baud rate. To
avoid getting ‘-1’ in the data reads, I
wait for serial data to become
available and when it does, I get it
and stuff it into a response array.
Except for the actual picture data,
all camera commands and responses
// camera responses to pay attention to in status second byte
#define CDATA 0x0A
#define CSYNC 0x0D
#define CACK 0x0E //byte 3 has the command ID being ACK'd
#define CNACK 0x0F // something bad happened, error in 3rd byte
Listing 2. LCD Setup Calls
Figure 3.
16 SERVO 05.2015