attiny85 lcd display pricelist
This is a small graphics library, specifically aimed at ATtiny microcontrollers, for the variety of small colour TFT displays available at low cost from suppliers like Adafruit, AliExpress, or Banggood:
It"s an updated version of my Tiny TFT Graphics Library. This latest version of the library supports both the classic ATtiny processors, such as the ATtiny85, and the new 0-series, 1-series, and 2-series ATtiny processors, such as the ATtiny402. Like the original library it allows you to plot points, draw lines, draw filled rectangles, and plot characters and text with an optional scale factor, in 16-bit colour.
This version adds the ability to plot outline rectanges, and outline and filled circles. I"ve included demo curve-plotting and histogram-plotting programs that adjust to fit any display.
This library supports TFT displays that use an SPI interface and require four pins to drive the display. This leaves one pin free on an 8-pin chip such as the ATtiny85 or ATtiny402. If you need more pins choose a larger chip, such as the ATtiny84 or ATtiny404.
Unlike my Compact TFT Graphics Library which uses standard Arduino SPI calls, this library uses direct I/O pin manipulations. This means that you can use any assignment of pins to the four I/O lines needed by the display, and makes it about twice as fast as one using SPI calls. I"ve also added support for some additional displays, so it now supports 16 different TFT displays.
On the classic ATtiny processors, such as the ATtiny85, the library uses the feature that you can toggle one or more bits in a port by writing to the PINB register; for example, to enable or disable the chip-select signal:
So provided you set all the pins to their disabled state at startup, the display routines can simply toggle the appropriate pins to enable or disable them.
The differences between each family of processors are handled by constants to define the pin assignments, and preprocessor macros to define the bit manipulations. If you use the circuits given below you won"t need to change anything, apart from specifying which display you"re using.
The ClearDisplay() routine has been optimised further by realising that we don"t need to keep setting the mosi bit, since to clear the display it is always zero, so the routine only needs to toggle the sck bit the appropriate number of times. I"m grateful to Thomas Scherer for suggesting this.
This library will work with displays based on the ST7735 which supports a maximum display size of 162x132, or the ST7789 and ILI9340/1 which support a maximum display size of 320x240. It includes parameters for the following colour TFT displays:
* These Adafruit displays conveniently all have the same edge-connector layout, so you can make a prototyping board or PCB that will take any of them, such as my Universal TFT Display Backpack.
Some of the AliExpress displays include a LDO 3.3V regulator, but not logic-level translation, so I recommend only interfacing them to a processor running from 3.3V.
The Adafruit displays all include an LDO 3.3V regulator and logic-level translation, so can be safely interfaced to processors powered from either 5V or 3.3V.
On the AliExpress red 160x128 display you need to connect the backlight pin to Vcc to turn it on. This doesn"t seem to be necessary with the other displays.
The library will probably support other TFT displays that use the same ST7735, ST7789, ILI9340/1 driver chips, but you may need to experiment with the parameters to get the image scaled and centered correctly.
The display needs to be connected to the microcontroller via four I/O lines: MOSI, SCK, CS, and DC. You can use any pins for these, but they should all be in the same port. You need to specify the port pin numbers of the pins you are using at the start of the Tiny TFT Graphics Library listing.
The 33kΩ pullup resistor from the display"s CS pin is optional; it is only needed on the AliExpress displays, and holds the chip select high to prevent the display from flickering while programming the ATtiny85.
The different displays are catered for by seven constants which specify the size of the display, the offsets relative to the area supported by the display driver, whether the display is inverted, the rotation value, and the order of the colours; for example:
By default the parameters give the correct orientation assuming you"re using the display with the header pins along the top, except in the case of the larger displays which have the header pins along the shorter edge, in which case the header pins are assumed to be on the left.
To check or adjust the values for each display you can run the TestChart() program, which draws a one-pixel border around the display area, and plots a red "F" to show the orientation:
The library will probably support other TFT displays that use the same driver chips, but you may need to experiment with the parameters to get the image scaled and centered correctly.
The library includes basic graphics routines for plotting points and drawing lines. These work on a conventional coordinate system with the origin at lower left. For example, on the 80x160 display:
By default the ATtiny85 runs at 1MHz. Choose Burn Bootloader to set the fuses for 8MHz operation, or your graphics will run rather slowly, then upload the program using an ISP (in-system programming) programmer such as Sparkfun"s Tiny AVR Programmer Board
Using an LCD on a small chip like an attiny85 is not really that hard and till recent I didnt even think it warranted an instructable, but I have received questions about it, so I may as well expand on the process.
With the attiny only having a max of 6 pins available, it goes without saying that it cannot directly control all the pins of the standard Hitachi based LCD"s
A little bit over a year ago, I described how to add an LCD to an Attiny or other chip, using only 2 pins. That circuit made use of an HC164 shift register, but as I2C modules for LCD"s are extremely cheap and even LCD"s with a module already in place also are dirt cheap, one might as well use I2C on the Attiny85.
I2CThe attiny85 can simulate I2C on PB2 (pin 7) (SCL) and PB0 (pin 5) (SDA). The "Wire" library that is used to read and write bytes from and to the I2C port on the arduino doesnt work on the attiny. It needs the TinyWireM library to act as an I2C master
The "NewLCD" library from Francisco Malpartida is my favorite library, but also that one fails in using I2C for the Attiny because it makes a call to the Wire library. A modification to make it work with Attiny85 can be found here.
The "Bro Hogan" library however does work. It is basically the same library as the standard arduino LCD library, but it is modified to recognize the Attiny85 and the Attiny2313 and then makes a call to "TinyWireM" rather than "Wire".
Adafruit also provides a libray that works with the Attiny85 and that is described in another instructable. I will be using the Bro Hogan library here.
Most problems you may encounter are related to the IDE getting confused regarding the libraries. If you are using the standard Arduino LCD library, best replace it by the Bro Hogan library. If you are using Malpartida"s library and want to keep that (as it is a great library), move it out of the way. Grab the entire folder and move it out of your sketchbook/libraries folder. Make sure you have the TinyWireM library installed and make sure your libraries are up to date.
Now obviously there is no bootloader for the attiny85, but the process of burning the bootloader sets the fuses of the attiny from factory mode, to the mode you want to use it in. So, presuming you use the Arduino as ISP,:
The Digispark compatible development board is an ATtiny85 based microcontroller. Similar in design to the Arduino line, only cheaper and much smaller. There is a whole host of available shields to extend the functionality.
A library that utilizes the I2C library for ATtiny85 so to control an I2C LCD screen. Largely based on the Digispark library. This library was supposed to be seamlessly working as the old LiquidCrystal I2C by Malpartida with normal arduinos and attinys. However because my Arduino 1.6.1 IDE wanted me to include the regular Wire library in every sketch and also some old sketches of mine wouldn"t work with this version, I decided to turn this into a dedicated ATtiny85 library for controlling the LCD screen through an I2C connection. Some minor changes, just to enforce separation of concerns in other words. Don"t forget the 4.7 ΚΩ resistors between the SDA and SCK lines and the Vcc.
This project demonstrates the ability of the Wokwi Arduino simulator. You can write code on ATtiny85 to drive an LCD2004 (4 rows, 20 column hardware) by yourself. You can learn to program as well as see the code in action. No hardare needed.
CodeLockAVR-LCD-M: The relay RE1 is activated. SwitchOpen deactivates RE1. After 16 seconds the relay RE2 is activated. SwitchClosed deactivates RE2. SwitchBarrier deactivates RE2 and activates RE1.2. WRITING YOUR CODE (For the first time): * 1 2 3 4 # 5 5 1 0 #
Two short beeps indicate that new user code is written.For opening the door press: 5 5 1 0 # (5 5 1 0 is your code)CodeLockAVR-LCD: The relay RE1 is activated 1 second.
CodeLockAVR-LCD-M: The relay RE1 is activated. SwitchOpen deactivates RE1. After 16 seconds the relay RE2 is activated. SwitchClosed deactivates RE2. SwitchBarrier deactivates RE2 and activates RE1.3. CHANGING THE CODE: * OldCode # NewCode #Example: * 5 5 1 0 # 6 6 1 0 #Two short beeps indicate that new user code is written.For opening the door press: 6 6 1 0 #CodeLockAVR-LCD: The relay RE1 is activated 1 second.
CodeLockAVR-LCD-M: The relay RE1 is activated. SwitchOpen deactivates RE1. After 16 seconds the relay RE2 is activated. SwitchClosed deactivates RE2. SwitchBarrier deactivates RE2 and activates RE1.___ DEMO files (Bascom) ________________
For codelcd-D1SIM.bas program downloading click here.___ DEMO files (Bascom) _______________________________________________________________________________________________________________________