|
FT81x Arduino Driver
|
Instatiate an FT81x context. More...
#include <FT81x.h>
Public Member Functions | |
| FT81x (int8_t cs1, int8_t cs2, int8_t dc) | |
| Initialize FT81x with hardware SPI. More... | |
| void | begin () |
| Initialize FT81x instance. | |
| void | sendCommand (const uint32_t cmd) |
| Send single command to FT81x chip. More... | |
| uint8_t | read8 (const uint32_t address) |
| Read 8 bits from FT81x address space. More... | |
| uint16_t | read16 (const uint32_t address) |
| Read 16 bits from FT81x address space. More... | |
| uint32_t | read32 (const uint32_t address) |
| Read 32 bits from FT81x address space. More... | |
| void | write8 (const uint32_t address, const uint8_t data) |
| Write 8 bits to FT81x address space. More... | |
| void | write16 (const uint32_t address, const uint16_t data) |
| Write 16 bits to FT81x address space. More... | |
| void | write32 (const uint32_t address, const uint32_t data) |
| Write 32 bits to FT81x address space. More... | |
| void | clear (const uint32_t color) |
| Write clear command to current display list. More... | |
| void | drawCircle (const int16_t x, const int16_t y, const uint8_t size, const uint32_t color) |
| Draw circle in current display list. More... | |
| void | drawRect (const int16_t x, const int16_t y, const uint16_t width, const uint16_t height, const uint8_t cornerRadius, const uint32_t color) |
| Draw rectangle in current display list. More... | |
| void | drawTri (const int16_t x1, const int16_t y1, const int16_t x2, const int16_t y2, const int16_t x3, const int16_t y3, const uint32_t color, const uint32_t bgcolor) |
| Draw triangle in current display list. Points must be defined in clockwise order. Only tested with equilateral tris. More... | |
| void | drawLine (const int16_t x1, const int16_t y1, const int16_t x2, const int16_t y2, const uint8_t width, const uint32_t color) |
| Draw line in current display list. More... | |
| void | beginLineStrip (const uint8_t width, const uint32_t color) |
| Start drawing a line strip. More... | |
| void | addVertex (const int16_t x, const int16_t y) |
| Add vertex to line strip. More... | |
| void | endLineStrip () |
| End line strio. More... | |
| void | drawLetter (const int16_t x, const int16_t y, const uint8_t font, const uint32_t color, const uint8_t letter) |
| Draw a single letter in current display list. More... | |
| void | drawText (const int16_t x, const int16_t y, const uint8_t font, const uint32_t color, const uint16_t options, const char text[]) |
| Draw a single line of text in current display list. More... | |
| void | drawBitmap (const uint32_t offset, const uint16_t x, const uint16_t y, const uint16_t width, const uint16_t height, const uint8_t scale, const uint8_t rot) |
| Draw bitmap data in current display list. More... | |
| void | overlayBitmap (const uint32_t offset, const uint16_t x, const uint16_t y, const uint16_t width, const uint16_t height, const uint8_t scale, const uint8_t rot) |
| Overlay bitmap data (add pixel values to existing pixels) More... | |
| void | drawSpinner (const int16_t x, const int16_t y, const uint16_t style, const uint16_t scale, const uint32_t color) |
| Draw a spinner in current display list. More... | |
| void | drawButton (const int16_t x, const int16_t y, const int16_t width, const int16_t height, const uint8_t font, const uint32_t textColor, const uint32_t buttonColor, const uint16_t options, const char text[]) |
| Draw a button. More... | |
| void | drawClock (const int16_t x, const int16_t y, const int16_t radius, const uint32_t handsColor, const uint32_t backgroundColor, const uint16_t options, const uint16_t hours, const uint16_t minutes, const uint16_t seconds) |
| Draw an analog clock. More... | |
| void | drawGauge (const int16_t x, const int16_t y, const int16_t radius, const uint32_t handsColor, const uint32_t backgroundColor, const uint16_t options, const uint8_t major, const uint8_t minor, const uint16_t value, const uint16_t range) |
| Draw a gauge. More... | |
| void | drawGradient (const int16_t x1, const int16_t y1, const uint32_t color1, const int16_t x2, const int16_t y2, const uint32_t color2) |
| Draw a gradient. More... | |
| void | drawScrollbar (const int16_t x, const int16_t y, const int16_t width, const int16_t height, const uint32_t foregroundColor, const uint32_t backgroundColor, const uint16_t options, const uint16_t value, const uint16_t size, const uint16_t range) |
| Draw a scrollbar. More... | |
| void | drawProgressbar (const int16_t x, const int16_t y, const int16_t width, const int16_t height, const uint32_t foregroundColor, const uint32_t backgroundColor, const uint16_t options, const uint16_t value, const uint16_t range) |
| Draw a progressbar. More... | |
| void | beginDisplayList () |
| Begin a new display list. | |
| void | swapScreen () |
| End the current display list and swap the screen. | |
| void | waitForCommandBuffer () |
| The command buffer can take 4 kBytes of data while display lists can hold 8 kBytes. For display lists > 4k and < 8k you may need to wait for the buffer to catch up. | |
| void | setRotation (const uint8_t rotation) |
| Set screen rotation. More... | |
| void | writeGRAM (const uint32_t offset, const uint32_t size, const uint8_t data[], const bool useProgmem=true) |
| Write data to general purpose graphics RAM (must be aligned to 4 bytes) More... | |
| void | loadImage (const uint32_t offset, const uint32_t size, const uint8_t data[], const bool useProgmem=true) |
| Load image data (JPEG, PNG) as bitmap into general purpose graphics RAM (must be aligned to 4 bytes) More... | |
| void | playAudio (const uint32_t offset, const uint32_t size, const uint16_t sampleRate, const uint8_t format, const bool loop) |
| Play audio data located in general purpose graphics RAM (must be aligned to 8 bytes) More... | |
| bool | isSoundPlaying () |
| Query whether sound is currently playing. More... | |
| void | setAudioVolume (const uint8_t volume) |
| Set the volume of the audio output. More... | |
| void | setSound (const uint8_t effect, const uint8_t pitch) |
| Set a sound effect and its pitch. More... | |
| void | playSound () |
| Play the sound defined by setSound() | |
| void | stopSound () |
| Stop audio output by playing silence. | |
| uint8_t | queryDisplay (const uint8_t cmd) |
| Query the display for data. More... | |
Protected Member Functions | |
| void | initFT81x () |
| Initialize the FT81x chip. | |
| void | initDisplay () |
| Initizalize the display. | |
| void | sendCommandToDisplay (const uint8_t cmd, const uint8_t numParams, const uint8_t *params) |
| Send command to display. More... | |
| void | cmd (const uint32_t cmd) |
| Write single command to the command buffer of the FT81x chip. More... | |
| void | startCmd (const uint32_t cmd) |
| Start a bulk-write to the command buffer of the FT81x chip. More... | |
| void | intermediateCmd (const uint32_t cmd) |
| Write an intermediate command to the command buffer of the FT81x chip during a bulk-write. More... | |
| void | endCmd (const uint32_t cmd) |
| Write a final command to the command buffer of the FT81x chip during a bulk-write. More... | |
| void | increaseCmdWriteAddress (uint16_t delta) |
| Increase the internal pointer to the command buffer. More... | |
| void | updateCmdWriteAddress () |
| Write the internal pointer to the command buffer to the FT81x chip. | |
| void | sendText (const char text[]) |
| Send text as the end of a command sequence. More... | |
| uint8_t | initBitmapHandleForFont (uint8_t font) |
| Load and return the correct bitmap handle for fonts 16-34. More... | |
Protected Attributes | |
| int8_t | cs1 |
| CS pin for FT81x. | |
| int8_t | cs2 |
| CS pin for display. | |
| int8_t | dc |
| Data/Command pin for display. | |
| uint16_t | cmdWriteAddress = 0 |
| Internal pointer to the command buffer of the FT81x chip. | |
Instatiate an FT81x context.
|
inline |
Initialize FT81x with hardware SPI.
| cs1 | Number of the pin connected to the board's CS1 pin |
| cs2 | Number of the pin connected to the board's CS2 pin |
| dc | Number of the pin connected to the board's DC pin |
| void FT81x::addVertex | ( | const int16_t | x, |
| const int16_t | y | ||
| ) |
Add vertex to line strip.
| x | x-coordinate of the vertex |
| y | y-coordinate of the vertex |
| void FT81x::beginLineStrip | ( | const uint8_t | width, |
| const uint32_t | color | ||
| ) |
Start drawing a line strip.
| width | Width of the line (1-6) |
| color | Color of the line |
| void FT81x::clear | ( | const uint32_t | color | ) |
Write clear command to current display list.
| color | Clear display using this color |
|
protected |
Write single command to the command buffer of the FT81x chip.
| cmd | 8-bit command to send to the chip |
| void FT81x::drawBitmap | ( | const uint32_t | offset, |
| const uint16_t | x, | ||
| const uint16_t | y, | ||
| const uint16_t | width, | ||
| const uint16_t | height, | ||
| const uint8_t | scale, | ||
| const uint8_t | rot | ||
| ) |
Draw bitmap data in current display list.
| offset | Offset in general purpose graphics RAM |
| x | x-coordinate for the top-left of the bitmap |
| y | y-coordinate for the top-left of the bitmap |
| width | Width of the bitmap |
| height | Height of the bitmap |
| scale | Scale to resize the bitmap by |
| rot | Rotation of the image, in degrees, around the centre of the bitmap (works best with square images) |
| void FT81x::drawButton | ( | const int16_t | x, |
| const int16_t | y, | ||
| const int16_t | width, | ||
| const int16_t | height, | ||
| const uint8_t | font, | ||
| const uint32_t | textColor, | ||
| const uint32_t | buttonColor, | ||
| const uint16_t | options, | ||
| const char | text[] | ||
| ) |
Draw a button.
| x | x-coordinate for the top-left of the button |
| y | y-coordinate for the top-left of the button |
| width | Width of the button |
| height | Height of the button |
| font | Font handle (16-34 are built-in fonts) |
| textColor | Color for the text |
| buttonColor | Color for the button |
| options | Option to use (e.g. FT81x_OPT_FLAT) |
| text | Text to draw, must be terminated by null character (e.g. "Hello World\0") |
| void FT81x::drawCircle | ( | const int16_t | x, |
| const int16_t | y, | ||
| const uint8_t | size, | ||
| const uint32_t | color | ||
| ) |
Draw circle in current display list.
| x | x-coordinate for the center of the circle |
| y | y-coordinate for the center of the circle |
| size | Radius of the circle |
| color | Color of the circle |
| void FT81x::drawClock | ( | const int16_t | x, |
| const int16_t | y, | ||
| const int16_t | radius, | ||
| const uint32_t | handsColor, | ||
| const uint32_t | backgroundColor, | ||
| const uint16_t | options, | ||
| const uint16_t | hours, | ||
| const uint16_t | minutes, | ||
| const uint16_t | seconds | ||
| ) |
Draw an analog clock.
| x | x-coordinate for the center of the clock |
| y | y-coordinate for the center of the clock |
| radius | Radius of the clock |
| handsColor | Color for the clock hands |
| backgroundColor | Color for the clock background |
| options | Option to use (e.g. FT81x_OPT_FLAT | FT81x_OPT_NOSECS) |
| hours | Hours clock hand |
| minutes | Minutes clock hand |
| seconds | Seconds clock hand |
| void FT81x::drawGauge | ( | const int16_t | x, |
| const int16_t | y, | ||
| const int16_t | radius, | ||
| const uint32_t | handsColor, | ||
| const uint32_t | backgroundColor, | ||
| const uint16_t | options, | ||
| const uint8_t | major, | ||
| const uint8_t | minor, | ||
| const uint16_t | value, | ||
| const uint16_t | range | ||
| ) |
Draw a gauge.
| x | x-coordinate for the center of the clock |
| y | y-coordinate for the center of the clock |
| radius | Radius of the clock |
| handsColor | Color for the clock hands |
| backgroundColor | Color for the clock background |
| options | Option to use (e.g. FT81x_OPT_FLAT | FT81x_OPT_NOTICKS) |
| major | Number of major subdivisions on the dial, 1-10 |
| minor | Number of minor subdivisions on the dial, 1-10 |
| value | Gauge indicated value between 0 and range |
| range | Maximum value |
| void FT81x::drawGradient | ( | const int16_t | x1, |
| const int16_t | y1, | ||
| const uint32_t | color1, | ||
| const int16_t | x2, | ||
| const int16_t | y2, | ||
| const uint32_t | color2 | ||
| ) |
Draw a gradient.
| x1 | x-coordinate for the starting point of the gradient |
| y1 | y-coordinate for the starting point of the gradient |
| color1 | Color for the starting point of the gradient |
| x2 | x-coordinate for the ending point of the gradient |
| y2 | y-coordinate for the ending point of the gradient |
| color2 | Color for the ending point of the gradient |
| void FT81x::drawLetter | ( | const int16_t | x, |
| const int16_t | y, | ||
| const uint8_t | font, | ||
| const uint32_t | color, | ||
| const uint8_t | letter | ||
| ) |
Draw a single letter in current display list.
| x | x-coordinate for the letter |
| y | y-coordinate for the letter |
| font | Font handle (16-34 are built-in fonts) |
| color | Color for the letter |
| letter | Letter to draw |
| void FT81x::drawLine | ( | const int16_t | x1, |
| const int16_t | y1, | ||
| const int16_t | x2, | ||
| const int16_t | y2, | ||
| const uint8_t | width, | ||
| const uint32_t | color | ||
| ) |
Draw line in current display list.
| x1 | x-coordinate for the start of the line |
| y1 | y-coordinate for the start of the line |
| x2 | x-coordinate for the end of the line |
| y2 | y-coordinate for the end of the line |
| width | Width of the line (1-6) |
| color | Color of the line |
| void FT81x::drawProgressbar | ( | const int16_t | x, |
| const int16_t | y, | ||
| const int16_t | width, | ||
| const int16_t | height, | ||
| const uint32_t | foregroundColor, | ||
| const uint32_t | backgroundColor, | ||
| const uint16_t | options, | ||
| const uint16_t | value, | ||
| const uint16_t | range | ||
| ) |
Draw a progressbar.
| x | x-coordinate of progressbar top-left |
| y | y-coordinate of progressbar top-left |
| width | Width of progressbar, if width is greater than height the progressbar is drawn horizontally |
| height | Height of progressbar, if height is greater than width the progressbar is drawn vertically |
| foregroundColor | Color for the progressbar foreground |
| backgroundColor | Color for the progressbar background |
| options | Option to use (e.g. FT81x_OPT_FLAT) |
| value | Displayed value of the progressbar, between 0 and range (inclusive) |
| range | Maximum value |
| void FT81x::drawRect | ( | const int16_t | x, |
| const int16_t | y, | ||
| const uint16_t | width, | ||
| const uint16_t | height, | ||
| const uint8_t | cornerRadius, | ||
| const uint32_t | color | ||
| ) |
Draw rectangle in current display list.
| x | x-coordinate for the top-left of the rectangle |
| y | y-coordinate for the top-left of the rectangle |
| width | Width of the rectangle |
| height | Height of the rectangle |
| cornerRadius | Corner radius of the rectangle |
| color | Color of the rectangle |
| void FT81x::drawScrollbar | ( | const int16_t | x, |
| const int16_t | y, | ||
| const int16_t | width, | ||
| const int16_t | height, | ||
| const uint32_t | foregroundColor, | ||
| const uint32_t | backgroundColor, | ||
| const uint16_t | options, | ||
| const uint16_t | value, | ||
| const uint16_t | size, | ||
| const uint16_t | range | ||
| ) |
Draw a scrollbar.
| x | x-coordinate of scrollbar top-left |
| y | y-coordinate of scrollbar top-left |
| width | Width of scrollbar, if width is greater than height the scrollbar is drawn horizontally |
| height | Height of scrollbar, if height is greater than width the scrollbar is drawn vertically |
| foregroundColor | Color for the scrollbar foreground |
| backgroundColor | Color for the scrollbar background |
| options | Option to use (e.g. FT81x_OPT_FLAT) |
| value | Displayed value of the scrollbar, between 0 and range (inclusive) |
| size | Size of scrollbar handle |
| range | Maximum value |
| void FT81x::drawSpinner | ( | const int16_t | x, |
| const int16_t | y, | ||
| const uint16_t | style, | ||
| const uint16_t | scale, | ||
| const uint32_t | color | ||
| ) |
Draw a spinner in current display list.
| x | x-coordinate for the spinner |
| y | y-coordinate for the spinner |
| style | The style of spinner, valid range is from 0 to 3. |
| scale | Scale to resize the bitmap by |
| color | Color for the spinner |
| void FT81x::drawText | ( | const int16_t | x, |
| const int16_t | y, | ||
| const uint8_t | font, | ||
| const uint32_t | color, | ||
| const uint16_t | options, | ||
| const char | text[] | ||
| ) |
Draw a single line of text in current display list.
| x | x-coordinate for the letter |
| y | y-coordinate for the letter |
| font | Font handle (16-34 are built-in fonts) |
| color | Color for the letter |
| options | Option to use (e.g. FT81x_OPT_CENTER) |
| text | Text to draw, must be terminated by null character (e.g. "Hello World\0") |
| void FT81x::drawTri | ( | const int16_t | x1, |
| const int16_t | y1, | ||
| const int16_t | x2, | ||
| const int16_t | y2, | ||
| const int16_t | x3, | ||
| const int16_t | y3, | ||
| const uint32_t | color, | ||
| const uint32_t | bgcolor | ||
| ) |
Draw triangle in current display list. Points must be defined in clockwise order. Only tested with equilateral tris.
| x1 | x-coordinate for the first triangle point |
| y1 | y-coordinate for the first triangle point |
| x2 | x-coordinate for the first triangle point |
| y2 | y-coordinate for the first triangle point |
| x3 | x-coordinate for the first triangle point |
| y3 | y-coordinate for the first triangle point |
| color | Color of the rectangle |
| bgcolor | Color of the background |
|
protected |
Write a final command to the command buffer of the FT81x chip during a bulk-write.
| cmd | 8-bit command to send to the chip |
| void FT81x::endLineStrip | ( | ) |
End line strio.
| x | x-coordinate of the vertex |
| y | y-coordinate of the vertex |
|
inlineprotected |
Increase the internal pointer to the command buffer.
| delta | Amount to increase the pointer by |
|
protected |
Load and return the correct bitmap handle for fonts 16-34.
|
protected |
Write an intermediate command to the command buffer of the FT81x chip during a bulk-write.
| cmd | 8-bit command to send to the chip |
| bool FT81x::isSoundPlaying | ( | ) |
Query whether sound is currently playing.
| void FT81x::loadImage | ( | const uint32_t | offset, |
| const uint32_t | size, | ||
| const uint8_t | data[], | ||
| const bool | useProgmem = true |
||
| ) |
Load image data (JPEG, PNG) as bitmap into general purpose graphics RAM (must be aligned to 4 bytes)
| offset | Offset in general purpose graphics RAM |
| size | Size of the data in bytes |
| data | Pointer to the data |
| useProgmem | Load data from PROGMEM (only affects AVR architectures like the Arduino Uno) |
| void FT81x::overlayBitmap | ( | const uint32_t | offset, |
| const uint16_t | x, | ||
| const uint16_t | y, | ||
| const uint16_t | width, | ||
| const uint16_t | height, | ||
| const uint8_t | scale, | ||
| const uint8_t | rot | ||
| ) |
Overlay bitmap data (add pixel values to existing pixels)
| offset | Offset in general purpose graphics RAM |
| x | x-coordinate for the top-left of the bitmap |
| y | y-coordinate for the top-left of the bitmap |
| width | Width of the bitmap |
| height | Height of the bitmap |
| scale | Scale to resize the bitmap by |
| rot | Rotation of the image, in degrees, around the centre of the bitmap (works best with square images) |
| void FT81x::playAudio | ( | const uint32_t | offset, |
| const uint32_t | size, | ||
| const uint16_t | sampleRate, | ||
| const uint8_t | format, | ||
| const bool | loop | ||
| ) |
Play audio data located in general purpose graphics RAM (must be aligned to 8 bytes)
| offset | Offset in general purpose graphics RAM |
| size | Size of the data in bytes |
| sampleRate | Sample rate for the audio data (e.g. 44100) |
| format | Audio data format (e.g. FT81x_AUDIO_FORMAT_LINEAR) |
| loop | Whether to loop the audio or stop at the end |
| uint8_t FT81x::queryDisplay | ( | const uint8_t | cmd | ) |
Query the display for data.
| cmd | 8-bit command to send to the display |
| uint16_t FT81x::read16 | ( | const uint32_t | address | ) |
| uint32_t FT81x::read32 | ( | const uint32_t | address | ) |
| uint8_t FT81x::read8 | ( | const uint32_t | address | ) |
| void FT81x::sendCommand | ( | const uint32_t | cmd | ) |
Send single command to FT81x chip.
| cmd | 32-bit command |
|
protected |
Send command to display.
| cmd | 8-bit command to send to the display |
| numParams | Number of parameters for the command |
| params | Pointer to the 8-bit data used as parameters |
|
protected |
Send text as the end of a command sequence.
| text | Text to send, must be terminated by null character (e.g. "Hello World\0") |
| void FT81x::setAudioVolume | ( | const uint8_t | volume | ) |
Set the volume of the audio output.
| volume | Number from 0 to 255 |
| void FT81x::setRotation | ( | const uint8_t | rotation | ) |
Set screen rotation.
| rotation | Use one of the pre-defined contants to set the rotation |
| void FT81x::setSound | ( | const uint8_t | effect, |
| const uint8_t | pitch | ||
| ) |
Set a sound effect and its pitch.
| effect | Sound effect |
| pitch | Pitch of the sound (MIDI note ranging from 21 to 82) if supported by the selected effect |
|
protected |
Start a bulk-write to the command buffer of the FT81x chip.
| cmd | 8-bit command to send to the chip |
| void FT81x::write16 | ( | const uint32_t | address, |
| const uint16_t | data | ||
| ) |
Write 16 bits to FT81x address space.
| address | 32-bit address |
| data | 16-bit value |
| void FT81x::write32 | ( | const uint32_t | address, |
| const uint32_t | data | ||
| ) |
Write 32 bits to FT81x address space.
| address | 32-bit address |
| data | 32-bit value |
| void FT81x::write8 | ( | const uint32_t | address, |
| const uint8_t | data | ||
| ) |
Write 8 bits to FT81x address space.
| address | 32-bit address |
| data | 8-bit value |
| void FT81x::writeGRAM | ( | const uint32_t | offset, |
| const uint32_t | size, | ||
| const uint8_t | data[], | ||
| const bool | useProgmem = true |
||
| ) |
Write data to general purpose graphics RAM (must be aligned to 4 bytes)
| offset | Offset in general purpose graphics RAM |
| size | Size of the data in bytes |
| data | Pointer to the data |
| useProgmem | Load data from PROGMEM (only affects AVR architectures like the Arduino Uno) |
1.8.18