pw_graphics: Move existing graphics modules

Change-Id: Ia1fbca1e4061b5d8e4d153f2aa7cbd0ad7f693b3
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/experimental/+/95847
Reviewed-by: Erik Gilling <konkers@google.com>
Commit-Queue: Anthony DiGirolamo <tonymd@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index fb97cda..ccfbfa9 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -38,13 +38,18 @@
 group("host") {
   deps = [
     ":host_tests(//targets/host:host_debug_tests)",
-    "//pw_color:tests_run(//targets/host:host_debug_tests)",
-    "//pw_draw:tests_run(//targets/host:host_debug_tests)",
-    "//pw_framebuffer:tests_run(//targets/host:host_debug_tests)",
+    "$dir_pw_color:tests_run(//targets/host:host_debug_tests)",
+    "$dir_pw_draw:tests_run(//targets/host:host_debug_tests)",
+    "$dir_pw_framebuffer:tests_run(//targets/host:host_debug_tests)",
 
     # See //applications/pw_lcd_display_host_imgui/README.md for instructions.
     "//applications/terminal_display:all(//targets/host:host_debug)",
   ]
+
+  # If building Pi Pico builds compile the elf2uf2 utility.
+  if (PICO_SRC_DIR != "") {
+    deps += [ "//targets/rp2040:elf2uf2(//targets/host:host_debug)" ]
+  }
 }
 
 # Arduino specific targets.
diff --git a/README.md b/README.md
index 327ef96..c344580 100644
--- a/README.md
+++ b/README.md
@@ -17,3 +17,83 @@
 `third_party/pigweed`. If you already cloned but forgot to `--recursive` run
 `git submodule update --init` to pull all submodules.
 
+
+## pw_graphics
+
+The [//pw_graphics](/pw_graphics) folder contains some libraries for drawing to
+an RGB565 framebuffer and displaying it on various platforms.
+
+The demo applications that make use of these libraries are:
+- [//applications/terminal_display](/applications/terminal_display)
+
+### Build instructions
+
+First time setup:
+
+```
+git clone --recursive https://pigweed.googlesource.com/pigweed/experimental
+cd experimental
+. ./bootstrap.sh
+pw package install imgui
+pw package install glfw
+pw package install stm32cube_f4
+```
+
+#### **[STM32F429-DISC1](https://www.st.com/en/evaluation-tools/32f429idiscovery.html)**
+
+Compile:
+
+```sh
+gn gen out --export-compile-commands --args="
+  dir_pw_third_party_stm32cube_f4=\"$PROJECT_DIR/.environment/packages/stm32cube_f4\"
+"
+ninja -C out
+```
+
+Flash:
+
+```
+openocd -f third_party/pigweed/targets/stm32f429i_disc1/py/stm32f429i_disc1_utils/openocd_stm32f4xx.cfg -c "program out/stm32f429i_disc1_stm32cube_debug/obj/applications/terminal_display/bin/terminal_demo.elf verify reset exit"
+```
+
+#### **Linux, Windows or Mac**
+
+Compile:
+
+```sh
+gn gen out --export-compile-commands --args="
+  dir_pw_third_party_imgui=\"$PROJECT_DIR/.environment/packages/imgui\"
+"
+ninja -C out
+```
+
+Run:
+
+```
+out/host_debug/obj/applications/terminal_display/bin/terminal_demo
+```
+
+#### **[Raspberry Pi Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/) Connected to an [ILI9341](https://www.adafruit.com/?q=ili9341&sort=BestMatch)**
+
+Clone the pico-sdk repo:
+```
+cd $HOME
+git clone https://github.com/raspberrypi/pico-sdk
+```
+
+Compile:
+
+```sh
+gn gen out --export-compile-commands --args="
+  PICO_SRC_DIR=\"$HOME/pico-sdk\"
+"
+ninja -C out
+```
+
+Create a uf2 file for flashing the Pico with:
+
+```sh
+./out/host_debug/obj/targets/rp2040/bin/elf2uf2 ./out/rp2040/obj/applications/terminal_display/bin/terminal_demo.elf ./out/rp2040/obj/applications/terminal_display/bin/terminal_demo.uf2
+```
+
+Copy `./out/rp2040/obj/applications/terminal_display/bin/terminal_demo.uf2` to your Pi Pico.
diff --git a/build_overrides/pigweed.gni b/build_overrides/pigweed.gni
index c7d0c75..1893937 100644
--- a/build_overrides/pigweed.gni
+++ b/build_overrides/pigweed.gni
@@ -30,21 +30,23 @@
       get_path_info("//pw_board_led_stm32f429i_disc1", "abspath")
   dir_pw_board_led_stm32cube =
       get_path_info("//pw_board_led_stm32cube", "abspath")
-  dir_pw_color = get_path_info("//pw_color", "abspath")
-  dir_pw_coordinates = get_path_info("//pw_coordinates", "abspath")
-  dir_pw_display = get_path_info("//pw_display", "abspath")
+  dir_pw_color = get_path_info("//pw_graphics/pw_color", "abspath")
+  dir_pw_coordinates = get_path_info("//pw_graphics/pw_coordinates", "abspath")
+  dir_pw_display = get_path_info("//pw_graphics/pw_display", "abspath")
   dir_pw_display_host_imgui =
-      get_path_info("//pw_display_host_imgui", "abspath")
-  dir_pw_display_null = get_path_info("//pw_display_null", "abspath")
+      get_path_info("//pw_graphics/pw_display_host_imgui", "abspath")
+  dir_pw_display_null =
+      get_path_info("//pw_graphics/pw_display_null", "abspath")
   dir_pw_display_pico_ili9341 =
-      get_path_info("//pw_display_pico_ili9341", "abspath")
+      get_path_info("//pw_graphics/pw_display_pico_ili9341", "abspath")
   dir_pw_display_stm32f429i_disc1_stm32cube_ili9341 =
-      get_path_info("//pw_display_stm32f429i_disc1_stm32cube_ili9341",
-                    "abspath")
+      get_path_info(
+          "//pw_graphics/pw_display_stm32f429i_disc1_stm32cube_ili9341",
+          "abspath")
   dir_pw_display_teensy_ili9341 =
-      get_path_info("//pw_display_teensy_ili9341", "abspath")
-  dir_pw_draw = get_path_info("//pw_draw", "abspath")
-  dir_pw_framebuffer = get_path_info("//pw_framebuffer", "abspath")
+      get_path_info("//pw_graphics/pw_display_teensy_ili9341", "abspath")
+  dir_pw_draw = get_path_info("//pw_graphics/pw_draw", "abspath")
+  dir_pw_framebuffer = get_path_info("//pw_graphics/pw_framebuffer", "abspath")
   dir_pw_spin_delay = get_path_info("//pw_spin_delay", "abspath")
   dir_pw_spin_delay_arduino =
       get_path_info("//pw_spin_delay_arduino", "abspath")
@@ -54,10 +56,11 @@
       get_path_info("//pw_spin_delay_stm32f429i_disc1", "abspath")
   dir_pw_spin_delay_stm32cube =
       get_path_info("//pw_spin_delay_stm32cube", "abspath")
-  dir_pw_touchscreen = get_path_info("//pw_touchscreen", "abspath")
-  dir_pw_touchscreen_null = get_path_info("//pw_touchscreen_null", "abspath")
+  dir_pw_touchscreen = get_path_info("//pw_graphics/pw_touchscreen", "abspath")
+  dir_pw_touchscreen_null =
+      get_path_info("//pw_graphics/pw_touchscreen_null", "abspath")
   dir_pw_touchscreen_teensy_stmpe610 =
-      get_path_info("//pw_touchscreen_teensy_stmpe610", "abspath")
+      get_path_info("//pw_graphics/pw_touchscreen_teensy_stmpe610", "abspath")
   dir_pw_touchscreen_teensy_xpt2046 =
-      get_path_info("//pw_touchscreen_teensy_xpt2046", "abspath")
+      get_path_info("//pw_graphics/pw_touchscreen_teensy_xpt2046", "abspath")
 }
diff --git a/pw_color/BUILD.gn b/pw_graphics/pw_color/BUILD.gn
similarity index 100%
rename from pw_color/BUILD.gn
rename to pw_graphics/pw_color/BUILD.gn
diff --git a/pw_color/color_test.cc b/pw_graphics/pw_color/color_test.cc
similarity index 100%
rename from pw_color/color_test.cc
rename to pw_graphics/pw_color/color_test.cc
diff --git a/pw_color/public/pw_color/color.h b/pw_graphics/pw_color/public/pw_color/color.h
similarity index 100%
rename from pw_color/public/pw_color/color.h
rename to pw_graphics/pw_color/public/pw_color/color.h
diff --git a/pw_color/public/pw_color/colors_endesga32.h b/pw_graphics/pw_color/public/pw_color/colors_endesga32.h
similarity index 100%
rename from pw_color/public/pw_color/colors_endesga32.h
rename to pw_graphics/pw_color/public/pw_color/colors_endesga32.h
diff --git a/pw_color/public/pw_color/colors_pico8.h b/pw_graphics/pw_color/public/pw_color/colors_pico8.h
similarity index 100%
rename from pw_color/public/pw_color/colors_pico8.h
rename to pw_graphics/pw_color/public/pw_color/colors_pico8.h
diff --git a/pw_coordinates/BUILD.gn b/pw_graphics/pw_coordinates/BUILD.gn
similarity index 100%
rename from pw_coordinates/BUILD.gn
rename to pw_graphics/pw_coordinates/BUILD.gn
diff --git a/pw_coordinates/public/pw_coordinates/vec2.h b/pw_graphics/pw_coordinates/public/pw_coordinates/vec2.h
similarity index 100%
rename from pw_coordinates/public/pw_coordinates/vec2.h
rename to pw_graphics/pw_coordinates/public/pw_coordinates/vec2.h
diff --git a/pw_coordinates/public/pw_coordinates/vec_int.h b/pw_graphics/pw_coordinates/public/pw_coordinates/vec_int.h
similarity index 100%
rename from pw_coordinates/public/pw_coordinates/vec_int.h
rename to pw_graphics/pw_coordinates/public/pw_coordinates/vec_int.h
diff --git a/pw_display/BUILD.gn b/pw_graphics/pw_display/BUILD.gn
similarity index 100%
rename from pw_display/BUILD.gn
rename to pw_graphics/pw_display/BUILD.gn
diff --git a/pw_display/public/pw_display/display.h b/pw_graphics/pw_display/public/pw_display/display.h
similarity index 100%
rename from pw_display/public/pw_display/display.h
rename to pw_graphics/pw_display/public/pw_display/display.h
diff --git a/pw_display_host_imgui/BUILD.gn b/pw_graphics/pw_display_host_imgui/BUILD.gn
similarity index 100%
rename from pw_display_host_imgui/BUILD.gn
rename to pw_graphics/pw_display_host_imgui/BUILD.gn
diff --git a/pw_display_host_imgui/README.md b/pw_graphics/pw_display_host_imgui/README.md
similarity index 100%
rename from pw_display_host_imgui/README.md
rename to pw_graphics/pw_display_host_imgui/README.md
diff --git a/pw_display_host_imgui/display.cc b/pw_graphics/pw_display_host_imgui/display.cc
similarity index 100%
rename from pw_display_host_imgui/display.cc
rename to pw_graphics/pw_display_host_imgui/display.cc
diff --git a/pw_display_host_imgui/glfw.gni b/pw_graphics/pw_display_host_imgui/glfw.gni
similarity index 100%
rename from pw_display_host_imgui/glfw.gni
rename to pw_graphics/pw_display_host_imgui/glfw.gni
diff --git a/pw_display_host_imgui/imgui.gni b/pw_graphics/pw_display_host_imgui/imgui.gni
similarity index 100%
rename from pw_display_host_imgui/imgui.gni
rename to pw_graphics/pw_display_host_imgui/imgui.gni
diff --git a/pw_display_null/BUILD.gn b/pw_graphics/pw_display_null/BUILD.gn
similarity index 100%
rename from pw_display_null/BUILD.gn
rename to pw_graphics/pw_display_null/BUILD.gn
diff --git a/pw_display_null/display.cc b/pw_graphics/pw_display_null/display.cc
similarity index 100%
rename from pw_display_null/display.cc
rename to pw_graphics/pw_display_null/display.cc
diff --git a/pw_display_pico_ili9341/BUILD.gn b/pw_graphics/pw_display_pico_ili9341/BUILD.gn
similarity index 100%
rename from pw_display_pico_ili9341/BUILD.gn
rename to pw_graphics/pw_display_pico_ili9341/BUILD.gn
diff --git a/pw_display_pico_ili9341/display.cc b/pw_graphics/pw_display_pico_ili9341/display.cc
similarity index 100%
rename from pw_display_pico_ili9341/display.cc
rename to pw_graphics/pw_display_pico_ili9341/display.cc
diff --git a/pw_display_stm32f429i_disc1_stm32cube_ili9341/BUILD.gn b/pw_graphics/pw_display_stm32f429i_disc1_stm32cube_ili9341/BUILD.gn
similarity index 100%
rename from pw_display_stm32f429i_disc1_stm32cube_ili9341/BUILD.gn
rename to pw_graphics/pw_display_stm32f429i_disc1_stm32cube_ili9341/BUILD.gn
diff --git a/pw_display_stm32f429i_disc1_stm32cube_ili9341/display.cc b/pw_graphics/pw_display_stm32f429i_disc1_stm32cube_ili9341/display.cc
similarity index 100%
rename from pw_display_stm32f429i_disc1_stm32cube_ili9341/display.cc
rename to pw_graphics/pw_display_stm32f429i_disc1_stm32cube_ili9341/display.cc
diff --git a/pw_display_teensy_ili9341/BUILD.gn b/pw_graphics/pw_display_teensy_ili9341/BUILD.gn
similarity index 100%
rename from pw_display_teensy_ili9341/BUILD.gn
rename to pw_graphics/pw_display_teensy_ili9341/BUILD.gn
diff --git a/pw_display_teensy_ili9341/README.md b/pw_graphics/pw_display_teensy_ili9341/README.md
similarity index 100%
rename from pw_display_teensy_ili9341/README.md
rename to pw_graphics/pw_display_teensy_ili9341/README.md
diff --git a/pw_display_teensy_ili9341/display.cc b/pw_graphics/pw_display_teensy_ili9341/display.cc
similarity index 100%
rename from pw_display_teensy_ili9341/display.cc
rename to pw_graphics/pw_display_teensy_ili9341/display.cc
diff --git a/pw_draw/BUILD.gn b/pw_graphics/pw_draw/BUILD.gn
similarity index 100%
rename from pw_draw/BUILD.gn
rename to pw_graphics/pw_draw/BUILD.gn
diff --git a/pw_draw/draw_test.cc b/pw_graphics/pw_draw/draw_test.cc
similarity index 100%
rename from pw_draw/draw_test.cc
rename to pw_graphics/pw_draw/draw_test.cc
diff --git a/pw_draw/public/pw_draw/draw.cc b/pw_graphics/pw_draw/public/pw_draw/draw.cc
similarity index 100%
rename from pw_draw/public/pw_draw/draw.cc
rename to pw_graphics/pw_draw/public/pw_draw/draw.cc
diff --git a/pw_draw/public/pw_draw/draw.h b/pw_graphics/pw_draw/public/pw_draw/draw.h
similarity index 100%
rename from pw_draw/public/pw_draw/draw.h
rename to pw_graphics/pw_draw/public/pw_draw/draw.h
diff --git a/pw_draw/public/pw_draw/font6x8.cc b/pw_graphics/pw_draw/public/pw_draw/font6x8.cc
similarity index 100%
rename from pw_draw/public/pw_draw/font6x8.cc
rename to pw_graphics/pw_draw/public/pw_draw/font6x8.cc
diff --git a/pw_draw/public/pw_draw/font_set.h b/pw_graphics/pw_draw/public/pw_draw/font_set.h
similarity index 100%
rename from pw_draw/public/pw_draw/font_set.h
rename to pw_graphics/pw_draw/public/pw_draw/font_set.h
diff --git a/pw_draw/public/pw_draw/pigweed_farm.h b/pw_graphics/pw_draw/public/pw_draw/pigweed_farm.h
similarity index 100%
rename from pw_draw/public/pw_draw/pigweed_farm.h
rename to pw_graphics/pw_draw/public/pw_draw/pigweed_farm.h
diff --git a/pw_draw/public/pw_draw/pigweed_farm.png b/pw_graphics/pw_draw/public/pw_draw/pigweed_farm.png
similarity index 100%
rename from pw_draw/public/pw_draw/pigweed_farm.png
rename to pw_graphics/pw_draw/public/pw_draw/pigweed_farm.png
Binary files differ
diff --git a/pw_draw/public/pw_draw/sprite_sheet.cc b/pw_graphics/pw_draw/public/pw_draw/sprite_sheet.cc
similarity index 100%
rename from pw_draw/public/pw_draw/sprite_sheet.cc
rename to pw_graphics/pw_draw/public/pw_draw/sprite_sheet.cc
diff --git a/pw_draw/public/pw_draw/sprite_sheet.h b/pw_graphics/pw_draw/public/pw_draw/sprite_sheet.h
similarity index 100%
rename from pw_draw/public/pw_draw/sprite_sheet.h
rename to pw_graphics/pw_draw/public/pw_draw/sprite_sheet.h
diff --git a/pw_draw/public/pw_draw/text_area.cc b/pw_graphics/pw_draw/public/pw_draw/text_area.cc
similarity index 100%
rename from pw_draw/public/pw_draw/text_area.cc
rename to pw_graphics/pw_draw/public/pw_draw/text_area.cc
diff --git a/pw_draw/public/pw_draw/text_area.h b/pw_graphics/pw_draw/public/pw_draw/text_area.h
similarity index 100%
rename from pw_draw/public/pw_draw/text_area.h
rename to pw_graphics/pw_draw/public/pw_draw/text_area.h
diff --git a/pw_framebuffer/BUILD.gn b/pw_graphics/pw_framebuffer/BUILD.gn
similarity index 100%
rename from pw_framebuffer/BUILD.gn
rename to pw_graphics/pw_framebuffer/BUILD.gn
diff --git a/pw_framebuffer/framebuffer_test.cc b/pw_graphics/pw_framebuffer/framebuffer_test.cc
similarity index 100%
rename from pw_framebuffer/framebuffer_test.cc
rename to pw_graphics/pw_framebuffer/framebuffer_test.cc
diff --git a/pw_framebuffer/public/pw_framebuffer/rgb565.h b/pw_graphics/pw_framebuffer/public/pw_framebuffer/rgb565.h
similarity index 100%
rename from pw_framebuffer/public/pw_framebuffer/rgb565.h
rename to pw_graphics/pw_framebuffer/public/pw_framebuffer/rgb565.h
diff --git a/pw_framebuffer/rgb565.cc b/pw_graphics/pw_framebuffer/rgb565.cc
similarity index 100%
rename from pw_framebuffer/rgb565.cc
rename to pw_graphics/pw_framebuffer/rgb565.cc
diff --git a/pw_touchscreen/BUILD.gn b/pw_graphics/pw_touchscreen/BUILD.gn
similarity index 100%
rename from pw_touchscreen/BUILD.gn
rename to pw_graphics/pw_touchscreen/BUILD.gn
diff --git a/pw_touchscreen/public/pw_touchscreen/touchscreen.h b/pw_graphics/pw_touchscreen/public/pw_touchscreen/touchscreen.h
similarity index 100%
rename from pw_touchscreen/public/pw_touchscreen/touchscreen.h
rename to pw_graphics/pw_touchscreen/public/pw_touchscreen/touchscreen.h
diff --git a/pw_touchscreen_null/BUILD.gn b/pw_graphics/pw_touchscreen_null/BUILD.gn
similarity index 100%
rename from pw_touchscreen_null/BUILD.gn
rename to pw_graphics/pw_touchscreen_null/BUILD.gn
diff --git a/pw_touchscreen_null/touchscreen.cc b/pw_graphics/pw_touchscreen_null/touchscreen.cc
similarity index 100%
rename from pw_touchscreen_null/touchscreen.cc
rename to pw_graphics/pw_touchscreen_null/touchscreen.cc
diff --git a/pw_touchscreen_teensy_stmpe610/BUILD.gn b/pw_graphics/pw_touchscreen_teensy_stmpe610/BUILD.gn
similarity index 100%
rename from pw_touchscreen_teensy_stmpe610/BUILD.gn
rename to pw_graphics/pw_touchscreen_teensy_stmpe610/BUILD.gn
diff --git a/pw_touchscreen_teensy_stmpe610/touchscreen.cc b/pw_graphics/pw_touchscreen_teensy_stmpe610/touchscreen.cc
similarity index 100%
rename from pw_touchscreen_teensy_stmpe610/touchscreen.cc
rename to pw_graphics/pw_touchscreen_teensy_stmpe610/touchscreen.cc
diff --git a/pw_touchscreen_teensy_xpt2046/BUILD.gn b/pw_graphics/pw_touchscreen_teensy_xpt2046/BUILD.gn
similarity index 100%
rename from pw_touchscreen_teensy_xpt2046/BUILD.gn
rename to pw_graphics/pw_touchscreen_teensy_xpt2046/BUILD.gn
diff --git a/pw_touchscreen_teensy_xpt2046/touchscreen.cc b/pw_graphics/pw_touchscreen_teensy_xpt2046/touchscreen.cc
similarity index 100%
rename from pw_touchscreen_teensy_xpt2046/touchscreen.cc
rename to pw_graphics/pw_touchscreen_teensy_xpt2046/touchscreen.cc
diff --git a/targets/rp2040/BUILD.gn b/targets/rp2040/BUILD.gn
index 50a5bf5..62e3c5d 100644
--- a/targets/rp2040/BUILD.gn
+++ b/targets/rp2040/BUILD.gn
@@ -34,6 +34,17 @@
     ]
     sources = [ "pico_logging_test_main.cc" ]
   }
+
+  config("elf2uf2_configs") {
+    include_dirs = [ "$PICO_SRC_DIR/src/common/boot_uf2/include" ]
+    cflags_cc = [ "-std=gnu++14" ]
+  }
+
+  pw_executable("elf2uf2") {
+    configs = [ ":elf2uf2_configs" ]
+    sources = [ "$PICO_SRC_DIR/tools/elf2uf2/main.cpp" ]
+    remove_configs = [ "$dir_pw_build:strict_warnings" ]
+  }
 }
 
 generate_toolchain("rp2040") {