@@ -108,37 +108,7 @@ A minimal example::
108
108
def log_temp():
109
109
log.add(temp=temperature())
110
110
111
- An example that runs through some of the functions of the log module API::
111
+ An example that runs through some of the functions of the log module API:
112
112
113
- from microbit import *
114
- import log
115
-
116
- # Configure the labels and select a time unit for the timestamp
117
- log.set_labels('temp', 'brightness', timestamp=log.SECONDS)
118
-
119
- # Send each data row to the serial output
120
- log.set_mirroring(True)
121
-
122
- # This decorator schedules this function to run every 10s 50ms
123
- @run_every(s=10, ms=50)
124
- def log_data():
125
- """Log the temperature and light level, and display an icon."""
126
- log.add(temp=temperature(), brightness=display.read_light_level())
127
- display.show(Image.SURPRISED)
128
- sleep(500)
129
-
130
- while True:
131
- if button_a.is_pressed() and button_b.is_pressed():
132
- display.show(Image.MEH)
133
- # Delete the log file using the "full" options, which takes
134
- # longer but ensures the data is wiped from the device
135
- log.delete(full=True)
136
- elif button_a.is_pressed():
137
- display.show(Image.HAPPY)
138
- # Log only the light level, the temp entry will be empty
139
- log.add({
140
- "brightness": display.read_light_level()
141
- })
142
- else:
143
- display.show(Image.CONFUSED)
144
- sleep(500)
113
+ .. include :: ../examples/data-logging.py
114
+ :code: python
0 commit comments