OlegGedzjuns / Displayer

asynchronous arduino library for interacting with seven-segment indicators with any number of displays

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Displayer

Asynchronous, flexible, customizable library for managing seven-segment indicators under Arduino control

  • Library size: 1 088 bytes
  • Minimum Memory Usage: 36 bytes

Important! May not be compatible with Servo library

Features:

  • asynchronous display refresh
  • user specified refresh rate (+/- 3Hz)
  • user specified number of displays
  • support different common pins ( cathode / anode )
  • display strings, negative or positive integers or floats
  • support for most latin characters ( excluding K, M, V, W, X, Z )

Guide:

Instalation

  1. Download the Displayer_vX.X.zip file added to the latest release.
  2. Unzip the downloaded archive into the folder "~Documents/Arduino/libraries/"

Use

  1. Include library header
#include <Displayer.h>
  1. Сreate two constant arrays listing segments pins and indicator common pins inside setup() and call Inintialization method
void setup()
{
	// From A to DP
	const short segmentPins[] = { 2, 3, 4, 5, 6, 7, 8, 9 };
	
	// From left to right
	const short сommonPins[] = { 13, 11, 10 };
	
	// No need to create a prototype of the Displayer class
	Displayer.Initialize
	(
		Common_cathode,			 // Common pin type on your display (Common_cathode or Common_anode) 
		segmentPins,			 // The array of segment pins you created 
		sizeof сommonPins/ sizeof(short),// Number of indicators 
		сommonPins,			 // The array of indicator pins you created 
		75				 // Required display refresh rate 
	);
}
  1. Call the Show() method to display something

Examples:

// Simple int counter
int number = 1;

void loop()
{
	Displayer.Show(number);
	++number;
	// you can lock the main cycle, the display will still be refreshing
	delay(1000);
}
// Simple float counter
float number = 0.f;

void loop()
{
	Displayer.Show(number);
	number += 0.1f;
	// you can lock the main cycle, the display will still be refreshing
	delay(1000);
}
// Show() method capabilities
void loop()
	// String will be displayed until the next Show() method call
	
	Show("ABCXF");
	// characters that cannot be displayed on the seven-segment indicator will be ignored
	// if string or number does not fit on the display, the right side will preferably be displayed.
	// On the display with 3 indicators the line will be displayed like this: "C F"
  	delay(1000);
	
	Show(12345);
	// On the display with 3 indicators the line will be displayed like this: "345"
  	delay(1000);
	
	Show(-0.125f);
	// The maximum possible number of decimal places will be displayed
	// First zero will be ignored
	// On the display with 3 indicators the line will be displayed like this: "-.125"
  	delay(1000);
}

Thanks to:

  • Ri0ee for helping with binary segment encoding
  • E for information about Arduino interruptions
  • and biokin for translation

About

asynchronous arduino library for interacting with seven-segment indicators with any number of displays

License:MIT License


Languages

Language:C++ 100.0%