Tuesday, January 26, 2021

Arduino as ISP Program Atmega8A Bare Chip

Unable to find Atmega8A in the Arduino target Board ? 

1. search board board.txt
2. usually could be found in <arduino-root-dir>/hardware/arduino/board.txt
3. copy paste (warning this is arduino 1.6.9 look-like)

scroll until you find

## Arduino NG or older w/ ATmega8

## ------------------------------

atmegang.menu.cpu.atmega8=ATmega8

atmegang.menu.cpu.atmega8.upload.maximum_size=7168

atmegang.menu.cpu.atmega8.upload.maximum_data_size=1024

atmegang.menu.cpu.atmega8.bootloader.low_fuses=0xdf

atmegang.menu.cpu.atmega8.bootloader.high_fuses=0xca

atmegang.menu.cpu.atmega8.bootloader.file=atmega8/ATmegaBOOT-prod-firmware-2009-11-07.hex

atmegang.menu.cpu.atmega8.build.mcu=atmega8

And add this block of code after,

atmegang.menu.cpu.atmega8bare=ATmega8-Factory

atmegang.menu.cpu.atmega8bare.upload.maximum_size=7168

atmegang.menu.cpu.atmega8bare.upload.maximum_data_size=1024

atmegang.menu.cpu.atmega8bare.bootloader.low_fuses=0xdf

atmegang.menu.cpu.atmega8bare.bootloader.high_fuses=0xca

atmegang.menu.cpu.atmega8bare.bootloader.file=atmega8/ATmegaBOOT-prod-firmware-2009-11-07.hex

atmegang.menu.cpu.atmega8bare.build.mcu=atmega8

atmegang.menu.cpu.atmega8bare.build.f_cpu=1000000L


Notice that the difference is by adding "atmegang.menu.cpu.atmega8bare.build.f_cpu=1000000L"
Since most of the chips/dev-board is using the 16MHz X-tal, and for my project requirement,
had to use the factory setting and run in minimum power consumption mode.

Program your UNO R3 or any Arduino dev-board to `Arduino as ISP` you could find it in
the example sketchbook. 

Good luck ^^

Tuesday, January 5, 2021

CableSense ioT, part 1

Introduction


Hi techies, this is the first part of my product release journal. Starting with simple practical 

electronic project, of a loop wire as antena connected to NPN a Darlington-setup to sense 

if a wire is 'hot', where electrical charge flows through it. 


The story behind of the simple built is that my electrical water-jet pump being active for long

period of time, a sign of leaking or left-open water valve. It frustrate me so much, increasing 

electricity and water bills and the worse part is wasting the fresh water and fossil fuel.


I were thinking for several approach to detect the leakage and stumbled-upon the simple schematic,

after seeing the wide range usage of the 'hot' wire sensing, to detect turned-On appliances to AC.

I've decided to go with the schematic built and go further with adding Wemos module, a board

that has microcontroller (uC) with bluetooth and internet-access feature.


The board sense the active wire, do log and send the log into the internet that later could be view

as summary etc. The board itself has SerialNumber for client identificacation, bluetooth mode that 

toggled via switch that received setting etc and toggled switch of the internet or active logging mode.


The first edition would only focus to these operations and there will be a later followup of a smart 

switch or relay to toggle the hot wire to On/Off. Part one would covered the schematic, board wiring, 

software and some unique ID setup.


Schematic

Drawn using easyeda.com

The built


Attach with Arduino

Lets continue to the 2nd part.. ^^.



Monday, January 4, 2021

Cable Sensor Circuit Detects SMPS Faulty of PC Accidentally

Building this nice simple yet practical circuit saved me alot. Okay, i got this
circuit design from multiple of websites and i built mine.
a. https://www.instructables.com/Invisible-Broken-Wire-Detector/
b. https://www.instructables.com/Wireless-AC-Current-Detector/



Circuit drawn with easyeda


Result 1 2



Video

After successful built it is time to test, i moved the detector to nearby cable,
plug the cable and switch On, voila works like charm! Then click switch Off
the detector Led would still On but dimmer... After troubleshooting  circuit
just works fine with other cable that is not in switches-hub i tested earlier.

Weird? i started to plugged off all cables one by one, until i unplugged PC' 
power cable. The detector Led stop completely... Nah! i now there is something
going on during the SMPS of my PC got plug in. It is still `On` and drawing some
electric actively and silently.

Lesson learned, by now i unplugged home-appliances that no longer being used ^^.

Tuesday, October 13, 2020

Change Docker Container localtime

There are 5 ways to change docker container' locatime, i chose
-v /etc/localtime:/etc/localtime:ro

Short blog, happy post ^^

Monday, September 28, 2020

Linux Generate md5 from command line

`echo` would always return with trailing new line char, therefore pass `-n` to
neglect the newline. And so md5sum would received a text from pipe with `-t`
option

 $ echo -n 123456 | md5sum -t

e10adc3949ba59abbe56e057f20f883e  -

Have fun ^^

Sunday, September 27, 2020

XMage, Adding MutateAbility (2)

Got the ETB triggers, by using the 

Ability abilityEquip = new EntersBattlefieldTriggeredAbility(
    new MutateEffect(Outcome.Mutate)
); 
abilityEquip.addTarget(targetNonHuman);
this.addAbility(abilityEquip);

While the MutatesSourceTriggeredAbility failed to trigger..
or probably it is triggered but there is something in the GameImpl
that treated it different way?

Saturday, September 26, 2020

Xmage, Client does not want to Run, as the Card Repository broken or error

If you experience the Card db or repository failure, then simply
Make sure you are in the Mage.Client dir 

$ pwd 
mage/Mage.Client

$ rm -rf db

And then re-run the client,
$ mvn exec:java -Dexec.mainClass="mage.client.MageFrame"

Hope it helps ^^

Friday, September 25, 2020

XMage, Setting Client And Server to TestMode

Mage.Client, go to SessionHandler.java and edit

public static boolean isTestMode() {

	return true;
    //return session.isTestMode();
}

Mage.Server, run is with additional argument set, -testMode=true


$ mvn exec:java -Dexec.mainClass="mage.server.Main" -Dexec.args="-testMode=true"

Happy testing ^^

XMage, Adding MutateAbility (1)

 Got gp66 forked repo to work on. Trying to test Gemrazer to implement

1. target controlled permanent non-human

@@ -2,36 +2,48 @@ package mage.cards.g;
 
 import mage.MageInt;
 import mage.abilities.Ability;
 import mage.abilities.common.MutatesSourceTriggeredAbility;
 import mage.abilities.effects.common.DestroyTargetEffect;
+import mage.abilities.effects.common.AttachEffect;
 ...
 import mage.constants.CardType;
+import mage.constants.Outcome;
 import mage.constants.SubType;
 import mage.constants.TargetController;
 import mage.filter.FilterPermanent;
 import mage.filter.common.FilterArtifactOrEnchantmentPermanent;
+import mage.filter.common.FilterControlledCreaturePermanent;
 import mage.target.TargetPermanent;
+import mage.constants.SubType;
+import mage.filter.predicate.Predicates;

...
 
public final class Gemrazer extends CardImpl {
 
-    private static final FilterPermanent filter
+	private static final FilterPermanent filter
             = new FilterArtifactOrEnchantmentPermanent("artifact or enchantment an opponent controls");
 
     static {
         filter.add(TargetController.OPPONENT.getControllerPredicate());
     }
 
+    private static final FilterPermanent filterCreatureNonHuman
+            = new FilterControlledCreaturePermanent("non-human creature you control");
+    
+    static {
+    	filterCreatureNonHuman.add(Predicates.not(SubType.HUMAN.getPredicate()));
+    }
+

@@ -43,10 +55,15 @@ public final class Gemrazer extends CardImpl {
         // Reach
         this.addAbility(ReachAbility.getInstance());
 
         // Trample
         this.addAbility(TrampleAbility.getInstance());
+        
+        // Whenever this creature mutates, attach to a controlled non-human creature
+        Ability abilityAttach = new MutatesSourceTriggeredAbility(new AttachEffect(Outcome.Mutate));
+        abilityAttach.addTarget(new TargetPermanent(filterCreatureNonHuman));
+        this.addAbility(abilityAttach);
 
         // Whenever this creature mutates, destroy target artifact or enchantment an opponent controls.
         Ability ability = new MutatesSourceTriggeredAbility(new DestroyTargetEffect());
         ability.addTarget(new TargetPermanent(filter));
         this.addAbility(ability);

2. Test the ability of mutated creature

 @Test
    public void testCastMutate() {
        addCard(Zone.BATTLEFIELD, playerA, "Forest", 2);
        addCard(Zone.BATTLEFIELD, playerA, "Plains", 1);
        addCard(Zone.BATTLEFIELD, playerA, "Flourishing Fox",1);
        addCard(Zone.HAND, playerA, "Gemrazer",1);

        castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Gemrazer using mutate");
        // But why no addTarget to flourishing fox ??
        
        setStrictChooseMode(true);
        setStopAt(1, PhaseStep.BEGIN_COMBAT);
        execute();
        assertAllCommandsUsed();

        assertAbility(playerA, "Gemrazer", new CyclingAbility(new ManaCostsImpl("{1}")), true);
        assertHandCount(playerA, 0);
    }

The test result so far so good

Todo:

Ask for the mutation on top or bottom of the targeted non-human creature.


Eclipse Maven build, recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0`

Error at Eclipse build, "... recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0`"

Solution:

Find your .m2 repository dir, in my Linux debian 10 is at ~/.m2

$ find . -name "<your-project-org.xxx.xxx.projectname>"
$ rm -f org/<your-project-org.xxx.xxx.projectname> <-- usually under the name of your project

at the command line of the project, 

$ mvn clean
$ mvn install -DskipTests=true

Reopen eclipse, reference here

select Porject -> Maven -> Update

Have fun ^^

Monday, July 13, 2020

Failed to install the following Android SDK packages as some licences have not been accepted.



Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;28.0.3 Android SDK Build-Tools 28.0.3 platforms;android-28 Android SDK Platform 28 If you stumbled upon the same error, then you could try these:

`yes | ./sdkmanager "platforms;android-28"`
`yes | ./sdkmanager "build-tools;28.0.3"`
`yes | ./sdkmanager --licenses`
You could find your sdkmanager executeable in linux by

$ locate sdkmanager

or

$ find / -name "sdkmanager"

Hope it helps.

Tuesday, June 16, 2020

ReactNative OneSignal Android failed to compile RNOneSignal.java because bunch of unhandled JSONException

If you compile ReactNative Android OneSignal plugin and hit the unhandled
JSONException that thrown or triggered by 
callback.invoke(RNUtils.jsonToWritableMap(outcomeEvent.toJSONObject()));

Simply add this:
-- callback.invoke(RNUtils.jsonToWritableMap(outcomeEvent.toJSONObject()));

++ try {
++     callback.invoke(RNUtils.jsonToWritableMap(outcomeEvent.toJSONObject()));
++ }
++ catch (JSONException je ) {
++     je.printStackTrace();
++     return;
++ }

Hope it help ^^

Wednesday, April 15, 2020

Linux Panda3D, ImportError: No module named direct.directbase.DirectStart

What to do if you see the Error Message:
ImportError: No module named direct.directbase.DirectStart
This error means it couldn’t find the Python modules – please make sure you are running the correct version of Python (probably Python 3.7, that depends on the Panda3D version) and that the panda3d.pth is located inside the Python site- packages directory.

I got this problem during Panda3D Linux installation. Searching for panda3d.pth also
can not be found. So this is what i done to get the installation to work.
1. follow all steps in the Panda3D website
2. My system is Debian 10 64bit,
    a file panda3d1.10_1.10.0_amd64.deb created
3. After sudo dpkg -i panda3d1.10_1.10.0_amd64.deb
4. set $PYTHONPATH in ~/.bashrc
    export PYTHONPATH=/opt/pythonprj/panda3d/panda3d-src/built:$PYTHONPATH
*/ 'built' depends to the directory where one compile or execute this
    python makepanda/makepanda.py --everything --installer
5. then run the environment by execute $ source ~/.bashrc or exit the terminal
    and relaunch, check with $ echo $PYTHONPATH, shud show the dir set at #4
6.
$ python
Python 3.6.9 (default, Dec 19 2019, 01:20:01) 
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from direct.showbase.ShowBase import ShowBase
>>>

it works! ^^