Since this is a pre-defined System Application in the MIRTOS Operating System, "all" that's needed is to configure one System Variable and the 12-byte Control Structure to which it points. First, set EEbLevels_UVIndex in EEPROM to be the index of the first of the twelve (12) uVars.B[##] BYTEs to use.
The example below configures the BYTEs immediately after the sixteen (16) used by the Pump Control example. That makes EEbLevels_UVIndex = EEbPumpCtrl_UVIndex + 16 = 32 + 16 = 48, or 0x30. The Control Structure then starts at that uVars.B[ EEbLevels_UVIndex ] value in SRAM, which is SRAM address 0x2B0. Given that starting point, the following Control Structure may be configured:
Offset | Variable name | SRAM Address | Value | Description, usage, notes |
---|---|---|---|---|
0 | wDisplayInterval | 0x2B0 | 500 | Interval between output updates |
2 | wLastUpdateTime | 0x2B2 | mSec | Timer starting millisecond value |
4 | bBitmapped | 0x2B4 | 0x02 | Bitmapped, with only 5 bits utilized |
BIT_PORT_0 | 0x2B4.0 | 2, which means PORTC |
The four (4) Low Order bits specify the PORT on which to output the LED data: 1=PORTB, 2=PORTC, and 3=PORTD for a 328P could be 0=PORTA to 10=PORTL for a 2560P | |
BIT_PORT_1 | 0x2B4.1 | |||
BIT_PORT_2 | 0x2B4.2 | |||
BIT_PORT_3 | 0x2B4.3 | |||
BIT__unused__4 | 0x2B4.4 | 0 | These three (3) bits are not used | |
BIT__unused__5 | 0x2B4.5 | 0 | ||
BIT__unused__6 | 0x2B4.6 | 0 | ||
BIT_BOTTOM_UP | 0x2B4.7 | 0 | Display the level BOTTOM-UP, instead of TOP-DOWN | |
5 | bOutputPins | 0x2B5 | 0x1C | Output PINS for the PORT above = B00011100 |
6 | bScalar | 0x2B6 | 10 | Divisor = 0-1023 AIn into 102 LEDs -> divide by 10 |
7 | bAnalogInput | 0x2B7 | 7 | Select Analog Input index = ADC7 |
8 | bOffset | 0x2B8 | 12 | Analog Input adjustment = subtract 12 |
9 | bBrightness | 0x2B9 | 64 | LED intensity = 64 (255 is the maximum) |
10 | bPump1SPsIndex | 0x2BA | 0x26 | Pump #1 Run & Stop Setpoints index = 38 |
11 | bPump2SPsIndex | 0x2BB | 0x2C | Pump #2 Run & Stop Setpoints index = 44 |
Here again, a script can be used to input this, with explanatory notes:
> E 0x2A = 48 ; Config starts at uVars.B[ 48 ] = 0x2B0 >ESW 0x2B0 = 500 mSec ; Interval = 0.500 seconds >ES 0x2B4 = 0x02 ; Bitmap (Port C) and "top down" >ES 0x2B5 = 0x1C ; Bitmap Output pins (B00011100) >ES 0x2B6 = 10 ; Scalar (10 -> 102 LEDs = 306 bytes) >ES 0x2B7 = 7 ; Select Analog Input = AIn(7) >ES 0x2B8 = 12 ; Offset from zero (i.e., subtract 12) >ES 0x2B9 = 64 ; LED intensity = 64 >ES 0x2BA = 0x26 ; Setpoints #1 begins: WORD at uVars.B[38] >ES 0x2BB = 0x2C ; Setpoints #2 begins: WORD at uVars.B[44] >E 1 |= 8 ; Enable the Level Display System Application >
To enter the same configuration in a little more compact form:
> E 42 = 48 >ESW 0x2B0 = 500 M >ES 0x2B4 = 2 28 10 7 12 64 38 44 >E 1 |= 8 >DV+ SRAM contents: 0280: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 0290: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 02A0: FA 00 0E 85 07 00 00 01-70 01 07 01 A0 00 40 01 ........p.....@. 02B0: F4 01 89 83 02 1C 0A 07-0C 40 26 2C 00 00 00 00 .........@&,.... >
The underlined values above are the configuration data. Even without actual WS2812 LEDs connected to be able to view the levels and setpoints, the "P?" command can be used to see the pixel data. Once this Level Display System Application is activated, all of the parameters in SRAM can be adjusted on the fly to tune up the output.
Notes: | |
The bScalar value is based on how many LEDs are being used to display the level and setpoints. The formula is: 1023 divided by the number of LEDs. If we had 64 LEDs, for example, 1023 / 64 = 17.05, so the bScalar value to would be 17. | |
Try toggling BIT_BOTTOM_UP to flip the output end-to-end. For the example configuration above, the toggle command would be "ES 0x2B4 ^= 128". |
See also: | |
The Pump Control System Application, the pixel command set, and the scripting language. |