subghz_scene_region_info.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include "../subghz_i.h"
  2. #include <furi_hal_region.h>
  3. void subghz_scene_region_info_on_enter(void* context) {
  4. SubGhz* subghz = context;
  5. const FuriHalRegion* const region = furi_hal_region_get();
  6. FuriString* buffer = furi_string_alloc();
  7. if(region) {
  8. furi_string_cat_printf(buffer, "Region: %s, bands:\n", region->country_code);
  9. for(uint16_t i = 0; i < region->bands_count; ++i) {
  10. furi_string_cat_printf(
  11. buffer,
  12. " %lu-%lu kHz\n",
  13. region->bands[i].start / 1000,
  14. region->bands[i].end / 1000);
  15. }
  16. } else {
  17. furi_string_cat_printf(buffer, "Region: N/A\n");
  18. }
  19. widget_add_string_multiline_element(
  20. subghz->widget, 0, 0, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(buffer));
  21. furi_string_free(buffer);
  22. view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdWidget);
  23. }
  24. bool subghz_scene_region_info_on_event(void* context, SceneManagerEvent event) {
  25. UNUSED(context);
  26. UNUSED(event);
  27. return false;
  28. }
  29. void subghz_scene_region_info_on_exit(void* context) {
  30. SubGhz* subghz = context;
  31. widget_reset(subghz->widget);
  32. }