Thursday, August 19, 2021

Use Echo Flex As Bluetooth Earphone

Use Echo Flex As Bluetooth Earphone



I found a new usage for Amazon Echo Flex, other than use it as a USB charger. I use Echo Flex as a bluetooth earphone while watching movie at night in the living room, so it doesn't disturb the others.

This is how I do it. I plug in the Echo Flex near the sofa, connect the (wire) eaphone to the Echo Flex with the 3.5mm plug. I connect my TV box to my Echo Flex as external speaker. Then I don't need a long wire earphone. The 3.5mm plug on the Echo Flex can only be used as audio ouput and not input.

I can use a bluetooth earphone, and I have a bluetooth earphone. By using the Echo Flex with a wire earphone, I don't worried about battery life and charging the bluetooth earphone.

Issue. Earlier I can not connect to the Echo Flex via bluetooth from the TV box. The TV box was unable to discover the Echo Flex as a bluetooth device. Then I enable the bluetooth setting of Echo Flex from the Alexa mobile app, then the Echo Flex is discovered by the TV box.

Alexa app > Devices > (Echo Flex) > Bluetooth ...

Once setup completed, the TV box automatically output the audio to Echo Flex (for my case).

Note: The Echo Flex use the bluetooth audio as input or output, but only output through the 3.5mm port.

Wednesday, August 04, 2021

Python: Polymorphism

Python: Polymorphism

A polymorphism in object orinted programming means a same function have more than 1 implementation.

An example of polymorphism in Python:

  > 9*3 ⇒ 27
  > '9'*3 ⇒ 999
  

You can define a multiple function:

  > multiple(9, 3)
  > multiple('9', 3)
  

Different variable type in the parameter produce different output.

Polymorphism: Breathing


class Human(object):
    def breathing(self):
        print('use lungs')

class Fish(object):
    def breathing(self):
        print('use gills')

def breathing(o):
    o.breathing()

alan= Human()
wanna= Fish()
breathing(alan)
breathing(wanna)
⇒ 
use lungs
use gills
  

Another coding:

for o in (alan,wanna):
    breathing(o)