Zumo32U4 library
Zumo32U4LCD.h
Go to the documentation of this file.
1// Copyright Pololu Corporation. For more information, see http://www.pololu.com/
2
5#pragma once
6
7#include <PololuHD44780.h>
8#include <FastGPIO.h>
9#include <USBPause.h>
10
34{
35 // Pin assignments
36 static const uint8_t rs = 0, e = 1, db4 = 14, db5 = 17, db6 = 13, db7 = IO_D5;
37
38public:
39
40 virtual void initPins()
41 {
43 }
44
45 virtual void send(uint8_t data, bool rsValue, bool only4bits)
46 {
47 // Temporarily disable USB interrupts because they write some pins
48 // we are using as LCD pins.
49 USBPause usbPause;
50
51 // Save the state of the RS and data pins. The state automatically
52 // gets restored before this function returns.
58
59 // Drive the RS pin high or low.
61
62 // Send the data.
63 if (!only4bits) { sendNibble(data >> 4); }
64 sendNibble(data & 0x0F);
65 }
66
67private:
68
69 void sendNibble(uint8_t data)
70 {
71 FastGPIO::Pin<db4>::setOutput(data >> 0 & 1);
72 FastGPIO::Pin<db5>::setOutput(data >> 1 & 1);
73 FastGPIO::Pin<db6>::setOutput(data >> 2 & 1);
74 FastGPIO::Pin<db7>::setOutput(data >> 3 & 1);
75
77 _delay_us(1); // Must be at least 450 ns.
79 _delay_us(1); // Must be at least 550 ns.
80 }
81};
82
static void setOutputLow() __attribute__((always_inline))
Configures the pin to be an output driving low.
Definition: FastGPIO.h:284
static void setOutput(bool value) __attribute__((always_inline))
Sets the pin as an output.
Definition: FastGPIO.h:318
static void setOutputHigh() __attribute__((always_inline))
Configures the pin to be an output driving high.
Definition: FastGPIO.h:296
General class for handling the HD44780 protocol.
Definition: PololuHD44780.h:57
Writes data to the LCD on the Zumo 32U4.
Definition: Zumo32U4LCD.h:34
virtual void initPins()
Definition: Zumo32U4LCD.h:40
virtual void send(uint8_t data, bool rsValue, bool only4bits)
Definition: Zumo32U4LCD.h:45