Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ ref_app/target.vcxproj.user
ref_app/tmp/
ref_app/x64
ref_app/bin/
examples/chapter*/bin
Binary file added examples/chapter09_07/images/seven_segment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 6 additions & 5 deletions examples/chapter09_07/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Example Chapter09_07

## Controlling a Seven Segment Display

Example chapter09_07 makes use of object oriented
Expand All @@ -8,20 +9,20 @@ programming methods to control a seven segment display.

In this example, port pins are used to control a
seven segment single-character display. As in most other examples,
both a hardware version for the target system as well as a simlulated
both a hardware version for the target system as well as a simulated
PC version are available. The PC version writes its
character to the output console.

## Application Description

The sixteen hexadecimal digits <img src="https://render.githubusercontent.com/render/math?math=0123456789\text{AbCdEF}">
The sixteen hexadecimal digits $0123456789AbCdEF$
are displayed sequentially, one digit per second.
The dot (_i_._e_., period or decimal point) is toggled
on and off for successive groups of 16 hexadecimal digits.
The user LED is simultaneously toggled at the usual $\frac{1}{2}~\text{Hz}$.

The application task is intuitive and easy to understand.
The followind code snippet from the application task
The following code snippet from the application task
`app::display::task_func`, for instance, depicts the control
responsible for writing the character digit and decimal
point on the seven segment display. The user LED is simultaneously
Expand Down Expand Up @@ -70,10 +71,10 @@ portable application layer code.
The screenshot below shows the PC simulation
of the display application task running in a console.

![](./images/seven_segment.pdf)
![screenshot of PC simulation](./images/seven_segment.png)

## Hardware Setup

The hardware setup is shown in the image below.

![](./images/board7.jpg)
![hardware setup](./images/board7.jpg)
5 changes: 3 additions & 2 deletions examples/chapter09_08/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Example Chapter09_08

## Controlling an RGB LED

Example chapter09_08 utilizes object oriented programming techniques
Expand All @@ -14,7 +15,7 @@ an underlying tick derived from a timer interrupt that
runs every $50~{\mu}\text{s}$.

In this example (as in most other examples), both a hardware
version for the target system as well as a simlulated PC
version for the target system as well as a simulated PC
version are available. For this exercise, it was
decided to implement a rather detailed PC simulation
using old-school traditional Win32-API programming.
Expand All @@ -30,4 +31,4 @@ The user LED is simultaneously toggled at the usual $\frac{1}{2}~\text{Hz}$.
The chapter09_08 Win32-API simulation in its Windows-based
application is shown in action in the image below.

![](./images/rgb_led_wnd_09_08.jpg)
![Capture of Win32-API simulation](./images/rgb_led_wnd_09_08.jpg)
6 changes: 3 additions & 3 deletions examples/chapter09_08/src/mcal/avr/mcal_led_monochrome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

util::device::led_monochrome& mcal::led::led_monochrome0()
{
using local_led_mponochrome_type =
mcal::led::led_momochrome_board<mcal::reg::portb, UINT8_C(5)>;
using local_led_monochrome_type =
mcal::led::led_monochrome_board<mcal::reg::portb, UINT8_C(5)>;

static local_led_mponochrome_type the_led { };
static local_led_monochrome_type the_led { };

return the_led;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
{
template<const std::uint8_t port_addr,
const std::uint8_t port_bpos>
class led_momochrome_board final : public util::device::led_monochrome
class led_monochrome_board final : public util::device::led_monochrome
{
public:
led_momochrome_board()
led_monochrome_board()
{
// Set the port pin value to low.
port_pin_type::set_pin_low();
Expand All @@ -31,7 +31,7 @@
port_pin_type::set_direction_output();
}

~led_momochrome_board() override = default;
~led_monochrome_board() override = default;

auto my_on() -> void override
{
Expand Down
27 changes: 14 additions & 13 deletions examples/chapter09_08a/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Example Chapter09_08a

## Controlling an RGB LED of type ws2812

Example chapter09_08a utilizes object oriented programming techniques
Expand All @@ -18,7 +19,7 @@ color bits is set to the value $1$ or $0$ depending on the
half-width of a low/high signal pair.

In this example (as in most other examples), both a hardware
version for the target system as well as a simlulated PC
version for the target system as well as a simulated PC
version are available. For this exercise, it was
decided to implement a rather detailed PC simulation
using old-school traditional Win32-API programming.
Expand Down Expand Up @@ -52,7 +53,7 @@ These very specific mcal/microcontroller-dependent parameters
are used to generate the real-time ws2812 control signal.

The third template parameter `LedCount` provides the ability
to link multiple ws2812 devices seqentially and control them
to link multiple ws2812 devices sequentially and control them
in an LED chain, as is common for this particular device.

In example chapter09_08a, a ws2812 LED device is used.
Expand All @@ -62,7 +63,7 @@ In example chapter09_08a, a ws2812 LED device is used.
The RGB-color-light-show in example chapter09_08a (this example)
differs slightly from the one in example chapter09_08 (the previous example).

In this example the color transitions are a bit lenghtier in time
In this example the color transitions are a bit lengthier in time
(instead of the normal $20~\text{ms}$). Also the color transitions
at and around the points $255~\text{bits}$-RGB
have been lengthened in time. This results in color emphasis
Expand All @@ -76,7 +77,7 @@ This enhanced RGB-color-light-show can be found in the file
The chapter09_08a Win32-API simulation in its Windows-based
application is shown in action in the image below.

![](./images/rgb_led_wnd_09_08a.jpg)
![Capture of Windows simulation](./images/rgb_led_wnd_09_08a.jpg)

## Hardware Setup

Expand All @@ -85,23 +86,23 @@ ARDUINO(R) placed on a breadboard with soldered-on pins.
The wiring is straightforward. The ws2812 port control uses port pin `portd.3`.

The hardware setup with the RGB LED in action is pictured
in the images below. The pictures show colorful RGB hues eminating
in the images below. The pictures show colorful RGB hues emanating
from the bright RGB LED of type ws2812.

![](./images/board09_08a_01r.jpg)
![](./images/board09_08a_02g.jpg)
![](./images/board09_08a_03b.jpg)
![Hardware setup - magenta hue emanating from LED](./images/board09_08a_01r.jpg)
![Hardware setup - green hue emanating from LED](./images/board09_08a_02g.jpg)
![Hardware setup - cyan hue emanating from LED](./images/board09_08a_03b.jpg)

### Bit Timing: ws2812

The approximate bit timing needed by the ws2812 is shown in the following table.

| Bit Value | $T_{hi}~\left[{ns}\right]$ | $T_{lo}~\left[{ns}\right]$ |
| --------- | --------------- | --------------- |
| $0$ | $350$ | $800$ |
| $1$ | $700$ | $600$ |
| --------- | -------------------------- | -------------------------- |
| $0$ | $350$ | $800$ |
| $1$ | $700$ | $600$ |

A sample partial-trace of the control signal on `portd.3` is shown
below in a representation of an image from a digital oscilloscpoe.
below in a representation of an image from a digital oscilloscope.

![](./images/ws2812_signal.jpg)
![View of trace captured on digital oscilloscope](./images/ws2812_signal.jpg)
5 changes: 3 additions & 2 deletions examples/chapter09_08b/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Example Chapter09_08b (variation 32-bit microcontroller)

## Controlling an RGB LED of type ws2812

Example chapter09_08b utilizes essentially the same techniques
Expand All @@ -20,7 +21,7 @@ A logic-AND gate shifts the microcontroller pin's voltage level.
The microcontroller is clocked at $24~\text{MHz}$.

The hardware setup with the RGB LED in action is pictured
in the image below. The pictures depicts a pink hue eminating
in the image below. The pictures depicts a pink hue emanating
from the bright RGB LED of type ws2812B.

![](./images/board09_08b.jpg)
![Hardware setup - pink hue emanating from LED](./images/board09_08b.jpg)
Loading