def _get_orientation_threaded(self):
     """
     Internal. called in a thread to continuously read the astro pi data
     """
     self.stopped = False
     self.running = True
     while(not self.stopped):
         self._orientation = AstroPi.get_orientation(self)
         sleep(self.sample_rate)
     self.running = False
    def __init__(
        self,
        imu_settings_file = 'RTIMULib',
        text_assets = 'sense_hat_text',
        sample_rate = 0.01):

        self.sample_rate = sample_rate
        
        AstroPi.__init__(self, imu_settings_file, text_assets)

        self._orientation = AstroPi.get_orientation(self)

        #start the orientation thread
        thread.start_new_thread(self._get_orientation_threaded, ())
        """
        self.ap.clear()
        self.mcastropi.clear()

#run
if __name__ == "__main__":

    print("SpaceCRAFT - Minecraft Interactive Astro Pi")

    #create connection to minecraft
    mc = Minecraft.create()

    #create the astro pi object
    ap = AstroPi()
    #read data from the astro pi to initialise it
    ap.get_orientation()
    ap.get_humidity()
    ap.get_pressure()

    #find the players position and create the astro pi 10 blocks above them
    pos = mc.player.getTilePos()
    pos.y += 10
    mcap = MCInteractiveAstroPi(mc, ap, pos)

    try:
        print("CTRL C to quit")
        while(True):
            #each time a block is hit pass it to the interactive astro pi
            for blockHit in mc.events.pollBlockHits():
                mcap.interact(blockHit.pos)
            #keep reading the astro pi orientation data otherwise it goes out of sync
Beispiel #4
0
        self.ap.clear()
        self.mcastropi.clear()


#run
if __name__ == "__main__":

    print("SpaceCRAFT - Minecraft Interactive Astro Pi")

    #create connection to minecraft
    mc = Minecraft.create()

    #create the astro pi object
    ap = AstroPi()
    #read data from the astro pi to initialise it
    ap.get_orientation()
    ap.get_humidity()
    ap.get_pressure()

    #find the players position and create the astro pi 10 blocks above them
    pos = mc.player.getTilePos()
    pos.y += 10
    mcap = MCInteractiveAstroPi(mc, ap, pos)

    try:
        print("CTRL C to quit")
        while (True):
            #each time a block is hit pass it to the interactive astro pi
            for blockHit in mc.events.pollBlockHits():
                mcap.interact(blockHit.pos)
            #keep reading the astro pi orientation data otherwise it goes out of sync