blob: 60291e11924ad302b50b0f470658ce87fbcc384b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
/*************************************************************************
* Arduino Text Display Library for Multiple LCDs
* Distributed under GPL v2.0
* Copyright (c) 2013 Stanley Huang <stanleyhuangyc@live.com>
* All rights reserved.
*************************************************************************/
#include <Arduino.h>
#include <Wire.h>
#include "MultiLCD.h"
#include "fonts.h"
void LCD_Common::printInt(uint16_t value, int8_t padding)
{
uint16_t den = 10000;
for (int8_t i = 5; i > 0; i--) {
byte v = (byte)(value / den);
value -= v * den;
den /= 10;
if (v == 0 && padding && den) {
if (padding >= i) {
writeDigit((m_flags & FLAG_PAD_ZERO) ? 0 : -1);
}
continue;
}
padding = 0;
writeDigit(v);
}
}
void LCD_Common::printLong(uint32_t value, int8_t padding)
{
uint32_t den = 1000000000;
for (int8_t i = 10; i > 0; i--) {
byte v = (byte)(value / den);
value -= v * den;
den /= 10;
if (v == 0 && padding && den) {
if (padding >= i) {
writeDigit((m_flags & FLAG_PAD_ZERO) ? 0 : -1);
}
continue;
}
padding = 0;
writeDigit(v);
}
}
|