Library for interfacing to Nokia 5110 LCD display (as found on the SparkFun website).

Dependents:   LV7_LCDtest LV7_Grupa5_Tim003_Zadatak1 lv7_Grupa5_Tim008_zad1 LV7_PAI_Grupa5_tim10_Zadatak1 ... more

This library is designed to make it easy to interface an mbed with a Nokia 5110 LCD display.

These can be found at Sparkfun (https://www.sparkfun.com/products/10168) and Adafruit (http://www.adafruit.com/product/338).

The library uses the SPI peripheral on the mbed which means it is much faster sending data to the display than other libraries available on other platforms that use software SPI.

The library can print strings as well as controlling individual pixels, meaning that both text and primitive graphics can be displayed.

Bitmap.cpp

Committer:
valavanisalex
Date:
2017-03-08
Revision:
38:92fad278c2c3
Child:
40:c9262294f2e1

File content as of revision 38:92fad278c2c3:

#include "Bitmap.h"

#include <iostream>

Bitmap::Bitmap(std::vector<int> const &contents,
               unsigned int const       height,
               unsigned int const       width)
    :
    _contents(contents),
    _height(height),
    _width(width)
{
    // Perform a quick sanity check of the dimensions
    if (contents.size() != height * height) {
        std::cerr << "Contents of bitmap has size " << contents.size()
                  << " pixels, but its dimensions were specified as "
                  << width << " * " << height << " = " << width * height;
    }
}

int Bitmap::get_pixel(unsigned int const row,
                      unsigned int const column) const
{
    // First check that row and column indices are within bounds
    if(column >= _width || row >= _height)
    {
        std::cerr << "The requested pixel with index " << row << "," << column
                  << "is outside the bitmap dimensions: " << _width << ","
                  << _height;
    }

    // Now return the pixel value, using row-major indexing
    return _contents[row * _width + column];
}