Skip to content

Commit 5877b12

Browse files
Adding Ball busy indicator.
1 parent 2941215 commit 5877b12

File tree

7 files changed

+99
-4
lines changed

7 files changed

+99
-4
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
# ArduinoLibrary
2+
23
A collection of objects and utilities for the Arduino.
34

45
* Timer
6+
- A class for executing code at a specifict rate without using delays
57
* Button
8+
- Add event handlers to physical button like 'click' or 'double click'
69
* Led
10+
- fade or flash an led without delays
711
* Relay
8-
* List
12+
- control a relay with timing
13+
* List
14+
- A generic template list class
15+
* Ball
16+
- display a busy indicator

examples/Ball/Ball.ino

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <Ball.h>
2+
#include <Timer.h>
3+
4+
void wait()
5+
{
6+
Serial.print(Ball);
7+
}
8+
9+
// The setup function is called once at startup of the sketch
10+
void setup()
11+
{
12+
Serial.begin(9600);
13+
14+
Timer.repeat(wait, 500);
15+
}
16+
17+
// The loop function is called in an endless loop
18+
void loop()
19+
{
20+
Timer.run();
21+
}

keywords.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ Led KEYWORD1
33
Relay KEYWORD1
44
Timer KEYWORD1
55
Alarm KEYWORD1
6+
Ball KEYWORD1

library.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ArduinoLibrary",
3-
"keywords": "arduino, button, led, list, relay, timer",
3+
"keywords": "arduino, button, led, list, relay, timer, wait-indicator, busy-indicator",
44
"description": "A collection of objects and utilities for the Arduino.",
55
"repository": {
66
"type": "git",
@@ -15,7 +15,7 @@
1515
}
1616
],
1717
"dependencies": [],
18-
"version": "2.0.0",
18+
"version": "2.1.0",
1919
"frameworks": "arduino",
2020
"platforms": ["atmelavr", "espressif"]
2121
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=ArduinoLibrary
2-
version=2.0.0
2+
version=2.1.0
33
author=Jonathan Meyer <jon@stejsoftware.com>
44
maintainer=Jonathan Meyer <jon@stejsoftware.com>
55
sentence=A collection of objects and utilities for the Arduino.

src/Ball.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include "Ball.h"
2+
3+
#define BALL "/-\\|"
4+
5+
BallClass::BallClass() : m_frame(0),
6+
m_auto_delete(false),
7+
m_ball_len(strlen(BALL))
8+
{
9+
}
10+
11+
BallClass::~BallClass()
12+
{
13+
}
14+
15+
const char BallClass::next() const
16+
{
17+
m_frame = ((m_frame + 1) % m_ball_len);
18+
return BALL[m_frame];
19+
}
20+
21+
size_t BallClass::printTo(Print &p) const
22+
{
23+
p.write(next());
24+
25+
if (m_auto_delete)
26+
p.write(char(8));
27+
}
28+
29+
void BallClass::setAutoDelete()
30+
{
31+
m_auto_delete = true;
32+
}
33+
34+
void BallClass::clearAutoDelete()
35+
{
36+
m_auto_delete = false;
37+
}
38+
39+
BallClass Ball;

src/Ball.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#ifndef _BALL_H
2+
#define _BALL_H
3+
4+
#include <Arduino.h>
5+
6+
class BallClass : public Printable
7+
{
8+
public:
9+
BallClass();
10+
~BallClass();
11+
12+
size_t printTo(Print &) const;
13+
const char next() const;
14+
15+
void setAutoDelete();
16+
void clearAutoDelete();
17+
18+
private:
19+
bool m_auto_delete;
20+
uint8_t m_ball_len;
21+
mutable uint8_t m_frame;
22+
};
23+
24+
extern BallClass Ball;
25+
26+
#endif // _BALL_H

0 commit comments

Comments
 (0)