// *************************************************************************
//
// Setting up a lilOS handheld device. STEP 2 files.
//
// Second step is to make sure we have the required files working. We need..
// • A touch screen that can run inder lilOS.
// • A SD card adapter. Typcially mounted on the screen. We need one.
//
// This is all about getting the file system setup, working and documented.
// Find the Sd initial folder setup in your :
// Arduino/libraries/LC_lilOS/extras/For SD card/
// Drag the system folder onto your SD card's root folder. Then reinsert your
// SD card into your hardware.
//
// For Wokwi : If you are a paying user, you can open the SD Card tab, select
// "upload complete folders" and Point it the the "For SD card" folder.
//
// As before : All these examples we'll be using our little handheld with an
// Adafruit PN 1947 for display and SD card slot.
//
// Documentation, it's all in the book :
// https://github.com/leftCoast/LC_libraryDocs/blob/main/LC_libraries.pdf
// *************************************************************************
#include <SD.h>
#include <adafruit_1947.h>
#include <LC_SPI.h>
#include <iconButton.h>
#define DISPLAY_CS 10 // These are the pins my hand held is using.
#define SD_CS 4 // You will need to replace these with the
#define BEEP_PIN 23 // Ones you are using on your device.
// A quick function to show an error in a uniform way. (optional)
void error(const char* inMsg) {
delay(2000); // If the first thing we do fails, we'll need this.
Serial.print("ERROR : "); // Label.
Serial.println(inMsg); // Message.
}
// A quick function to halt the processor because the hardware is not
// going to work. In a uniform way as well. (Also optional)
void halt(const char* function) {
delay(2000); // If the first thing we do fails, we'll need this.
Serial.print("HALTING PROCESS IN : "); // Tell 'em so they don't wonder.
Serial.print(function); // And tell 'em where we stopped.
Serial.println("()"); // Make it look right as well.
while(1); // Lock down!
}
// See if we can get everything running..
void setup() {
Serial.begin(9600); // Serial port for debugging.
screen = new adafruit_1947(DISPLAY_CS,-1); // We create our screen object.
if (!screen) { // Didn't get a screen?
error("No screen."); // Tell the user.
halt(__func__); // Halt the program and tell the user where.
} //
if (!screen->begin()) { // Have a go at initialising the screen.
error("screen begin() failed."); // Failed? Tell the user.
halt(__func__); // Halt the program and tell the user where.
} //
screen->fillScreen(&black); // Have a go at making the sreen.. black.
if (!SD.begin(SD_CS)) { // Have a go at initializing the SD drive.
error("SD.begin() failed."); // Failed? Tell the user.
halt(__func__); // Halt the program and tell the user where.
} //
tone(BEEP_PIN,300,100); // See if the thing can make a beep sound.
iconButton* aBtn = new iconButton(50,50,"/system/icons/standard/check32.bmp");
aBtn->draw();
Serial.println("See a black screen with a green checkmark icon?");
Serial.println("If so, you're SD drive is working and your files");
Serial.println("seem to be in the correct place. Hit return in");
Serial.println("the serial monitor for next test..");
while(!Serial.available()) delay(10);
delete(aBtn);
bmpObj* aPic = new bmpObj(0,0,240,320,"System/images/solitude.bmp");
aPic->draw();
Serial.println();
Serial.println("Got a picuture of a girl on a rock? If so, this");
Serial.println("test is complete! Good job!");
}
// Nonthing to do here as yet.
void loop() { }