global_functions module
Contains functions invoked by several different parts of the code.
- global_functions.adjust_gauge_lims(curr_val, gauge)
For circular gauges. Adjusts upper/lower limits to nearest round numbers
- Parameters:
curr_val (float) – Value to be shown on gauge
gauge (
AA_Gauge) – Which gauge to update
- global_functions.blitRotate2(surf, image, topleft, angle)
Rotate an image around its center (instead of top corner)
- Parameters:
surf (pygame.Surface) – pygame surface to blit to
image (pygame.image) – image to be rotated
topleft (int) – top-left co-ord of image
angle (int) – rotate by this angle
- Returns:
- w (int):
width
- w2 (int):
width2
- global_functions.blit_some_stats(screen, width, day, date, hour_sec, fps, cpu_pct, cpu_temp, wifi_name, wifi_symbol, bluetooth_img)
These pieces of info are always displayed in the top bar or in the Okudagrams.
- Parameters:
screen (pygame.Screen) – Screen surface for blitting
width (int) –
day (string) –
date (string) –
hour_sec (string) –
fps (float) –
cpu_pct (float) –
cpu_temp (float) –
wifi_name (string) – Name of currently connected wifi (if any)
wifi_symbol (pygame.image) – Wifi symbol
bluetooth_img (pygame.image) – Bluetooth symbol
- global_functions.flip_buttons(pressed_button, button_list)
Unselect all other buttons except the one just pressed
- Parameters:
pressed_button (button) – Pressed button that called this function
button_list (list) – List of all buttons on this page
- global_functions.get_date_time()
Get formatted time for top toolbar display
- Returns:
day, date, hour_sec
- Return type:
string, string, string
- global_functions.get_text_dimensions(text='', font_style='FONT_DIN', font_color='WHITE', style=0, font_size=28)
Return size of to-be-rendered text
- Parameters:
text (string) – Find size of this text
font_style (pygame.font) – Choice of font affects dimensions, default is
FONT_DIN.font_color (pygame.Color) – Color defaults to
WHITEstyle (int) –
0for normal (default),1for boldfont_size (int) – size of text
- Returns:
- surf (pygame.Surface):
Surface of rendered text (not used)
- w (int):
width (in px) of to-be-rendered tex
- h (int):
height (in px) of to-be-rendered text
- global_functions.get_wifi_name()
Returns name of wifi network if connected.
- Return wifi_name:
Name of network if connected, “No WiFi” otherwise
- Return type:
string
- global_functions.my_map(x, in_min, in_max, out_min, out_max)
Standard mapping formula. Used in many places
- Note:
Standard formula
- Custom:
Custom
- Parameters:
x (float/int) – Input value to be mapped
in_min (float/int) – Least possible value for input
in_max (float/int) – Max possible value for input
out_min (float/int) – Least possible value for output
out_max (float/int) – Max possible value for output
- Returns:
Scaled value
- Return type:
float
- global_functions.print_global()
Prints the battery level
- global_functions.update_cpu_stats(dt=None)
Get rapsberry pi usage stats
- Returns:
- cpu_pct (float):
CPU % in use
- cpu_temp (float):
CPU temperature in C