import multiprocessing
import unicornhathd as unicornhat
import importlib
import sys
import os

import app.programs.hd


class State:
    ''' Handles the Unicorn HAT state'''

    def __init__(self):
        self._process = None

    def start_program(self, name, params={}):
        try:
            program = getattr(app.programs.hd, name)
        except AttributeError:
            raise ProgramNotFound(name)

        self.stop_program()

        if params.get("brightness") is not None:
            unicornhat.brightness(float(params["brightness"]))

        if params.get("rotation") is not None:
            unicornhat.rotation(int(params["rotation"]))

        self._process = multiprocessing.Process(target=program.run, args=(params,))
        self._process.start()

    def stop_program(self):
        if self._process is not None:
            self._process.terminate()
        unicornhat.show()


class ProgramNotFound(Exception):
    pass
@@ -89,16 +89,83 @@
 ort os%0A%0A
+import unicornhat%0Aimport unicornhathd%0Aimport app.programs.original%0A
 import a
@@ -253,24 +253,36 @@
 _init__(self
+, is_hd=True
 ):%0A        s
@@ -302,16 +302,248 @@
 = None%0A%0A
+        if is_hd is True:%0A            self._unicornhat = unicornhathd%0A            self._app_programs = app.programs.hd%0A        else:%0A            self._unicornhat = unicornhat%0A            self. app_programs = app.programs.original%0A%0A%0A
     def 
@@ -623,28 +623,34 @@
 getattr(
+self._
 app
-.
+_
 programs
 .hd, nam
@@ -641,19 +641,16 @@
 programs
-.hd
 , name)%0A
@@ -803,32 +803,38 @@
 ne:%0A            
+self._
 unicornhat.brigh
@@ -920,32 +920,38 @@
 ne:%0A            
+self._
 unicornhat.rotat
@@ -1207,16 +1207,22 @@
         
+self._
 unicornh

Allow state to set unicorn hat model