AberLED shield library
Library for the bicolor LED (and TFT screen) shield used in CS12020
The library for the AberLED shield.

Please see the AberLEDClass for more details.

Introduction

This library allows the use of the AberLED shield which consists of an 8x8 bicolor display and five buttons and lets you write simple games. The name "AberLED" is a historical accident - until very recently it used a bicolor LED display. The library still allows this style of shield to be used, however.

The library should come as a zip file, which you should import into your Arduino IDE using the library import tool (Sketch menu/Import Library../ Add Library..). Once imported it can be added to projects.

Including the AberLED.h file will create an object called AberLED of the class AberLEDClass. To use it, all the function names described under AberLEDClass should be prefixed with AberLED.

Warning
If you have a shield with an array of LEDs in a white box (and LED matrix) instead of a little black screen (a TFT display), you will need use AberLED.begin(AF_LEDDISPLAY) in your setup() function!

Here's a minimal example:

#include <AberLED.h>
void setup(){
AberLED.begin(); // or AberLED.begin(true) for a TFT display
Serial.begin(9600);
}
bool b[]={false,false,false,false,false};
void loop(){
delay(1);
for(int i=0;i<5;i++){
if(AberLED.getButton(i+1))
b[i] = !b[i];
}
for(int i=0;i<5;i++){
if(b[i])
AberLED.set(i,1,RED);
}
Serial.println(AberLED.getTicks());
}

Dealing with colour vision deficiencies

If you have problems with colour vision you may find it difficult to differentiate some of the display colours. If you are using a TFT display board, you can set a custom colour map by passing an argument to AberLED.begin.

static uint8_t cols[] = {
// each row is the actual red, green, blue pixel values
// for a each colour (BLACK, RED, GREEN, YELLOW)
30,30,30, // BLACK will now be dark grey
128,128,128, // GREEN will now be mid grey
255,128,0, // RED will now be orange
128,128,255, // YELLOW will now be pale blue
};
void setup() {
// tell the library we are using a TFT display with the
// colour definitions above
}

Copyright and Licensing

1 The majority of the code driving the TFT display is based on
2 https://github.com/Bodmer/TFT_ST7735
3 which currently has no license details, but is based on the Adafruit GFX
4 library - see below.
5 
6 The remainder is
7 Copyright 2014-2023 Jim Finnis, Aberystwyth University.
8 
9 This code is released under the terms of the MIT License:
10 
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is
16 furnished to do so, subject to the following conditions:
17 
18 The above copyright notice and this permission notice shall be included in
19 all copies or substantial portions of the Software.
20 
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 THE SOFTWARE.
28 
29 
30 Adafruit_GFX ORIGINAL LIBRARY LICENSE:
31 
32 vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvStartvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
33 
34 Software License Agreement (BSD License)
35 
36 Copyright (c) 2012 Adafruit Industries. All rights reserved.
37 
38 Redistribution and use in source and binary forms, with or without
39 modification, are permitted provided that the following conditions are met:
40 
41 - Redistributions of source code must retain the above copyright notice,
42  this list of conditions and the following disclaimer.
43 - Redistributions in binary form must reproduce the above copyright notice,
44  this list of conditions and the following disclaimer in the documentation
45  and/or other materials provided with the distribution.
46 
47 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
48 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
50 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
51 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
52 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
53 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
54 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
55 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
56 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
57 POSSIBILITY OF SUCH DAMAGE.
58 
59 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^End^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^