Adding a new layout for schedulingGetImage
At some point, it may be desirable to add a new layout for schedulingGetImage. This will need to happen mainly in cplusplussource/layouts.cpp
. The easiest way to add a layout is to copy a different layout (such as drawImage7), then modify it. Some useful information on this follows:
This function sets the sleep time for the device based off of the increment submitted. Increment is a positive integer in seconds. It will try to make all of your Wall-Ink devices refresh at the same time. If you set your increment to 1800 (30 minutes), it will tell them to refresh 2 minutes before the next half-hour mark. For example, setSleepTime(1800);
. It returns the time until the device will next check in, in seconds.
This function is taken from the Adafruit GFX library. Use this to set the font used by drawFancyString
. For example, canvas->setFont(&FreeSansBold18pt7b);
. A list of usable fonts can be found in cplusplussource/fonts.h
.
This function is taken from the Adafruit GFX library. Sets the text color. Should work with 1 or 0. For example, canvas->setTextColor(1);
This function is taken from the Adafruit GFX library. Sets whether text drawn by drawFancyString
will wrap around the edge of the screen. For example, ```canvas->setTextWrap(false);``
Draws a string with the settings set by the above functions. The coordinate it takes in corresponds with the upper-left corner of the text. For example, drawFancyString(currentTitle, 8, 140);
Takes in the reservations
array and returns a vector with the information organized into a more usable format. For example, std::vector<reservation> reservs = parseReservations(reservations);
Draws a rectangle of the specified size & color at the specified spot. For example, ```drawRect(xOffset, yOffset, 48, 23, 1);
Returns the width the text would be, were it to be drawn. For example, getTextWidth("foo");
Draws a QR code onto the screen at (x,y). The QR code is generated with str
and scale
, where scale
is a multiplier for pixel width & height. It returns the size of the QR code image. For example, putQrCode(333,10,websiteUrl,2);
Takes in an integer index to the reservation array and returns the human-readable 24hr time that the index corresponds with. For example, std::string time = reservationBlockToTime(5);
Takes in a string from the reservationBlockToTime
function, and returns a string formatted in a 12-hour format. For example, std::string time = militaryTimeToNormalPersonTime(reservationBlockToTime(5));
An array of reservation titles at various times of day. Each string is initialized to "Available"
. Each string corresponds with a 30-minute time block (in chronological order). The first block corresponds with 6:00am-6:30am.
This is the canvas that is being drawn on. The pixel buffer is also pointed to by the uint8_t* image
variable.
Edit the layouts.h
header to contain a declaration for your function.
There's a big, long if statement in image.cpp's main function that defines the screen resolution based off of the device type. Make sure to define a screen resolution for the device type corresponding with your layout.
There's another big, long if statement that looks at the device type and calls a corresponding drawImage function. Make sure that your function can get called here.
Edit web/plugin_dependencies/general_scheduling/schedulingGetDeviceType.php
so that the device type corresponding with your layout is an option.