Enfoce pure virtual base for MonochromeLed

- Switch the rp2040 target to use a PicoMonochromeLed instance instead
  of implementing base class methods.
- Disable direct instantiation of the MonochromeLed class; instead it
  must be subclassed.

Change-Id: I9500e1f4a4dc96f2dc8f7798c4c9c566d7d2579f
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/showcase/rp2/+/220632
Commit-Queue: Keir Mierle <keir@google.com>
Reviewed-by: Ted Pudlik <tpudlik@google.com>
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
diff --git a/device/BUILD.bazel b/device/BUILD.bazel
index 5187fd6..5d19895 100644
--- a/device/BUILD.bazel
+++ b/device/BUILD.bazel
@@ -28,6 +28,7 @@
 cc_library(
     name = "pico_led",
     srcs = ["pico_led.cc"],
+    hdrs = ["pico_led.h"],
     deps = [
         "//modules/led:monochrome_led",
         "@pico-sdk//src/common/pico_stdlib:pico_stdlib",
diff --git a/device/pico_led.cc b/device/pico_led.cc
index e576ead..49b9463 100644
--- a/device/pico_led.cc
+++ b/device/pico_led.cc
@@ -14,6 +14,8 @@
 
 // SimpleLED implementation for the rp2040 using the pico-sdk.
 
+#include "device/pico_led.h"
+
 #include "modules/led/monochrome_led.h"
 #include "pico/stdlib.h"
 #include "pw_digital_io_rp2040/digital_io.h"
@@ -25,12 +27,12 @@
     .polarity = pw::digital_io::Polarity::kActiveHigh,
 });
 
-MonochromeLed::MonochromeLed() {
+PicoMonochromeLed::PicoMonochromeLed() {
   led.Enable();
   Set(false);
 }
 
-void MonochromeLed::Set(bool enable) {
+void PicoMonochromeLed::Set(bool enable) {
   led.SetState(enable ? pw::digital_io::State::kActive
                       : pw::digital_io::State::kInactive);
 }
diff --git a/device/pico_led.h b/device/pico_led.h
new file mode 100644
index 0000000..ed4fa4f
--- /dev/null
+++ b/device/pico_led.h
@@ -0,0 +1,28 @@
+// Copyright 2024 The Pigweed Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+//     https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+// SimpleLED implementation for the rp2040 using the pico-sdk.
+
+#include "modules/led/monochrome_led.h"
+
+namespace am {
+
+/// Implementation of MonochromeLed that drives the Pi Pico's on-board LED.
+class PicoMonochromeLed : public MonochromeLed {
+ public:
+  PicoMonochromeLed();
+  virtual void Set(bool) override;
+};
+
+}  // namespace am
diff --git a/modules/led/monochrome_led.h b/modules/led/monochrome_led.h
index 31ccf23..b427ea3 100644
--- a/modules/led/monochrome_led.h
+++ b/modules/led/monochrome_led.h
@@ -18,7 +18,6 @@
 /// Interface for a simple LED.
 class MonochromeLed {
  public:
-  MonochromeLed();
   virtual ~MonochromeLed() = default;
 
   /// Returns whether the LED is on.
@@ -34,6 +33,8 @@
   void Toggle();
 
  protected:
+  MonochromeLed();
+
   /// Turns the LED on the board on or off.
   ///
   /// @param  enable  True turns the LED on; false turns it off.
diff --git a/targets/rp2040/system.cc b/targets/rp2040/system.cc
index 3bf12e4..30b65d1 100644
--- a/targets/rp2040/system.cc
+++ b/targets/rp2040/system.cc
@@ -14,6 +14,7 @@
 
 #include "system/system.h"
 
+#include "device/pico_led.h"
 #include "modules/board/board.h"
 #include "modules/led/monochrome_led.h"
 
@@ -25,7 +26,7 @@
 }
 
 am::MonochromeLed& MonochromeLed() {
-  static ::am::MonochromeLed monochrome_led;
+  static ::am::PicoMonochromeLed monochrome_led;
   return monochrome_led;
 }