subghz_scene_region_info.c 1.2 KB

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