-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NF] Support for 7-segment display (#9)
Added basic support for 7-segment display. The colon delimiter is not yet properly handled, but digits and dots should work.
- Loading branch information
Showing
34 changed files
with
705 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ pico-examples | |
robot_output.xml | ||
report.html | ||
mono_crash* | ||
.DS_Store | ||
.DS_Store | ||
venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
using System; | ||
using Antmicro.Renode.Core; | ||
using Antmicro.Renode.Logging; | ||
|
||
namespace Antmicro.Renode.Peripherals.Miscellaneous | ||
{ | ||
public class SegmentDisplay : IPeripheral, IGPIOReceiver | ||
{ | ||
public SegmentDisplay(int segments = 7, int cells = 1, int colon = 0) | ||
{ | ||
sync = new object(); | ||
NumberOfSegments = segments; | ||
NumberOfCells = cells; | ||
Colon = colon; | ||
this.segments = new bool[NumberOfSegments]; | ||
this.cells = new bool[NumberOfCells]; | ||
Reset(); | ||
} | ||
|
||
public void Reset() | ||
{ | ||
for (int c = 0; c < NumberOfCells; ++c) | ||
{ | ||
this.cells[c] = false; | ||
} | ||
|
||
for (int s = 0; s < NumberOfSegments; ++s) | ||
{ | ||
this.segments[s] = false; | ||
} | ||
} | ||
|
||
public void OnGPIO(int number, bool value) | ||
{ | ||
if (number >= NumberOfSegments + NumberOfCells) | ||
{ | ||
return; | ||
} | ||
|
||
// if cells change | ||
if (number < NumberOfCells) | ||
{ | ||
SetCell(number, value); | ||
} | ||
else | ||
{ | ||
SetSegment(number - NumberOfCells, value); | ||
} | ||
} | ||
|
||
public event Action<SegmentDisplay, bool[], bool[]> StateChanged; | ||
|
||
public void SetSegment(int number, bool state) | ||
{ | ||
lock (sync) | ||
{ | ||
if (segments[number] != state) | ||
{ | ||
segments[number] = state; | ||
StateChanged?.Invoke(this, cells, segments); | ||
this.Log(LogLevel.Noisy, "Segment[{0}] state changed to: {1}", number, state); | ||
} | ||
} | ||
} | ||
|
||
public void SetCell(int number, bool state) | ||
{ | ||
lock (sync) | ||
{ | ||
if (cells[number] != state) | ||
{ | ||
cells[number] = state; | ||
StateChanged?.Invoke(this, cells, segments); | ||
this.Log(LogLevel.Noisy, "Cell[{0}] state changed to: {1}", number, state); | ||
} | ||
} | ||
} | ||
|
||
public bool[] Segments | ||
{ | ||
get => segments; | ||
} | ||
|
||
public bool[] Cells | ||
{ | ||
get => cells; | ||
} | ||
|
||
|
||
public readonly int NumberOfSegments; | ||
public readonly int NumberOfCells; | ||
public readonly int Colon; | ||
|
||
private readonly object sync; | ||
private bool[] segments; | ||
private bool[] cells; | ||
} | ||
} |
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
{ | ||
"files": { | ||
"main.css": "/static/css/main.7bab5a1f.css", | ||
"main.js": "/static/js/main.75be53a9.js", | ||
"main.css": "/static/css/main.25333aef.css", | ||
"main.js": "/static/js/main.233f68a9.js", | ||
"static/media/Raspberry_Pi_Pico_top.png": "/static/media/Raspberry_Pi_Pico_top.e33f028f5df6fa7a8812.png", | ||
"static/media/breadboard.svg": "/static/media/breadboard.0b169a51ffbe1f7f8bd530e8f6cb7ed8.svg", | ||
"static/media/7segment.svg": "/static/media/7segment.4e0006b1fe808cef9373e141218a4d64.svg", | ||
"static/media/button.svg": "/static/media/button.477b4b211bc442f2c7af47352b66f76c.svg", | ||
"static/media/led.svg": "/static/media/led.4768c0df04932f68cd84bba91e9f7349.svg", | ||
"static/media/7segment_separator.svg": "/static/media/7segment_separator.4e74319228a46dc74746ad8d50353228.svg", | ||
"index.html": "/index.html", | ||
"main.7bab5a1f.css.map": "/static/css/main.7bab5a1f.css.map", | ||
"main.75be53a9.js.map": "/static/js/main.75be53a9.js.map" | ||
"main.25333aef.css.map": "/static/css/main.25333aef.css.map", | ||
"main.233f68a9.js.map": "/static/js/main.233f68a9.js.map" | ||
}, | ||
"entrypoints": [ | ||
"static/css/main.7bab5a1f.css", | ||
"static/js/main.75be53a9.js" | ||
"static/css/main.25333aef.css", | ||
"static/js/main.233f68a9.js" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>React App</title><script defer="defer" src="/static/js/main.75be53a9.js"></script><link href="/static/css/main.7bab5a1f.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html> | ||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>React App</title><script defer="defer" src="/static/js/main.233f68a9.js"></script><link href="/static/css/main.25333aef.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html> |
2 changes: 2 additions & 0 deletions
2
visualization/visualization/build/static/css/main.25333aef.css
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
visualization/visualization/build/static/css/main.25333aef.css.map
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
visualization/visualization/build/static/css/main.7bab5a1f.css
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
visualization/visualization/build/static/css/main.7bab5a1f.css.map
This file was deleted.
Oops, something went wrong.
30 changes: 15 additions & 15 deletions
30
...lization/build/static/js/main.75be53a9.js → ...lization/build/static/js/main.233f68a9.js
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
visualization/visualization/build/static/js/main.233f68a9.js.map
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
visualization/visualization/build/static/js/main.75be53a9.js.map
This file was deleted.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
.../visualization/build/static/media/7segment.4e0006b1fe808cef9373e141218a4d64.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.