stationeers.de Mod workshop · Dominik1199
DE Sign in
  1. Home
  2. IC10 academy
  3. Day 286

Day 286 of 365 · Expert · Month 10: Bits and data

Project: text display

A display that talks: state as text, temperature as “T=22C” assembled from digits at run time, alternating every two seconds.

Project 45 min Week 41

What you learn today

  • Show states as text
  • Alternating texts
  • Combine number and text

A single small display in the corridor should show two things: whether the temperature is fine and exactly how warm it is. Alternating, as text. For that you need everything from this week: STR(), fields with ins, bits with ext and the display's string mode.

The setup

DevicePrefabName
Gas sensorStructureGasSensor“Raum”
LED displayStructureConsoleLED5“Info”

Combining number and text

STR() cannot read registers. But every character is an 8-bit field, and digits are ASCII codes: “0” is 48, “1” is 49 and so on. So you take a template and insert the digits at run time:

CharacterT=tensunitsC
Bits32–3924–3116–238–150–7

STR("T=00C") is the template. You work out tens and units with div, floor and mod, add 48 and put them into place with ins.

Alternating texts

A tick counter counts up. Bit 2 of the counter switches between 0 and 1 every four ticks – exactly the rhythm for the alternation. ext tmp tick 2 1 pulls it out without you needing a second counter.

Milestones

  1. The display is in string mode and shows “OK” at 22 °C.
  2. Below 18 °C it shows “LOW”, above 26 °C “HIGH”.
  3. In the number phase it shows “T=22C”, with two digits even at 5 °C (“T=05C”).
  4. Every four ticks the display switches between state and number.
  5. Without the sensor it only shows “ERROR”.
Tip

The temperature has to be between 0 and 99 before splitting it. clamp temp temp 0 99 makes sure that in heat “T=99C” appears instead of a broken character.

Warning

“T=00C” has five characters. More than six do not fit into one number – “T=22.5C” is therefore impossible. Always plan display texts with a character count.

Project task

Task

Build the text display following the milestones above. The defines and aliases are already there.

Milestones

  1. Milestone 1: string mode and OK
  2. Milestone 2: LOW and HIGH
  3. Milestone 3: number as text
  4. Milestone 4: switch every 4 ticks
  5. Milestone 5: sensor missing

Hints

Hint 1

Tens: div digit temp 10, floor, add digit digit ASCII0, ins numtext digit 16 8.

Hint 2

Units: mod digit temp 10, plus 48, ins numtext digit 8 8.

Hint 3

Alternation: add tick tick 1, ext tmp tick 2 1, select text tmp numtext text.

Quiz

2 questions. You pass from 60 % – the server does the grading.

Complete the day

  • Passed all milestones of the project
  • Passed the quiz with at least 60 %

Without an account progress is saved in this browser only.

Report a mistake in this lesson

Please sign in to report. Sign in

Esc
↑ ↓ selectEnter open/ opens search anywhere