LG light cls list

owly

闇の伝説
Staff member
戦闘 コーダー

1.Mutatable
2. Algorithm
3. DiSkillV2
4. DiHelloWorld:DiSkillV2
5. Chobits
 

owly

闇の伝説
Staff member
戦闘 コーダー
on the up side it's more Arduino oriented for PID like projects.
on the other there will be no separation between the logic and the hardware,
so it would rely on machine code.

cool.

:s69:
 

fukurou

the supreme coder
ADMIN
Python:
class DiSkill:
    def __init__(self):
    pass

    # skill triggers and algorithmic logic
    def input(self, ear: str, skin: str, eye: str):
        pass
 

fukurou

the supreme coder
ADMIN
Python:
class Chobits:

    def __init__(self):
        super().__init__()
        self._dClasses: list[DiSkillV2] = []  # _ is a private access modifier

    def addSkill(self, skill: DiSkillV2) -> Chobits:
        # add a skill (builder design patterned func))
        self._dClasses.append(skill)
        return self

    def clearSkills(self):
        # remove all skills
        self._dClasses.clear()

    def addSkills(self, *skills: DiSkillV2):
        for skill in skills:
            skill.setKokoro(self._kokoro)
            self._dClasses.append(skill)

    def think(self, ear: str, skin: str, eye: str) -> str:
        for dCls in self._dClasses:
            self.inOut(dCls, ear, skin, eye)
 

owly

闇の伝説
Staff member
戦闘 コーダー
C++:
class code skeleton:
#ifndef Skill_H
#define Skill_H
class Skill{
   private:
  
   public:
   
};
#endif
C++:
class Chobit
{
private:

public:

};

team fuki going old school. reminds me of my Pascal days
 
Last edited:

owly

闇の伝説
Staff member
戦闘 コーダー
list :
C++:
class List {
public:
  byte length;
  byte data[16];
  void append(byte item) {
  if (length < 16) data[length++] = item;
 }
  void remove(byte index) {
  if (index >= length) return;
 memmove(&data[index], &data[index+1], length -
index - 1);
 length--;
 }
};
List l { .length = 3, .data = { 12, 82, 29 } };
l.remove(1);
 

owly

闇の伝説
Staff member
戦闘 コーダー
C++:
#ifndef Skill_H
#define Skill_H
// using Arduino hardware codes outside main:
#include <Arduino.h>
class Skill{
 private:

 public:
 Skill(){}
 void inOut(byte ear, byte skin, byte eye)
 {

 }
};
#endif
 

owly

闇の伝説
Staff member
戦闘 コーダー
C++:
#define LED_PIN 13
// import the C++ file with the example Led class:
class Led{
 private:
 byte pin;
 public:
 Led(){this->pin = 13;}
 Led(byte pin){
 this->pin = pin;
 }
 void init(){
 pinMode(pin, OUTPUT);
 }
 void on(){
 digitalWrite(pin, HIGH);
 }
 void off(){
 digitalWrite(pin, LOW);
 }
};
class Skill{
 private:
  Led _l1;
 public:
 Skill(Led l1){_l1 = l1;_l1.init();}
 void inOut(byte ear, byte skin, byte eye)
 {
    // turn the LED on (HIGH is the voltage level)
 _l1.on();
 delay(1000); // Wait for 1000 millisecond(s)
 // turn the LED off by making the voltage LOW
 _l1.off();
 delay(1000); // Wait for 1000 millisecond(s)
 }
};
Led led1(LED_PIN);
Skill s1(led1);
void setup()
{
 led1.init();
}
void loop()
{
  s1.inOut(1, 2, 3);
}
 

owly

闇の伝説
Staff member
戦闘 コーダー
C++:
#define LED_PIN 13
// import the C++ file with the example Led class:
class Led{
 private:
 byte pin;
 public:
 Led(){this->pin = 13;}
 Led(byte pin){
 this->pin = pin;
 }
 void init(){
 pinMode(pin, OUTPUT);
 }
 void on(){
 digitalWrite(pin, HIGH);
 }
 void off(){
 digitalWrite(pin, LOW);
 }
};
class Skill{
 virtual void inOut(byte ear, byte skin, byte eye) = 0;
};
class DiHelloWorld: Skill{
 private:
  Led _l1;
 public:
 DiHelloWorld(Led l1){_l1 = l1;_l1.init();}
 void inOut(byte ear, byte skin, byte eye)
 {
    // turn the LED on (HIGH is the voltage level)
 _l1.on();
 delay(1000); // Wait for 1000 millisecond(s)
 // turn the LED off by making the voltage LOW
 _l1.off();
 delay(1000); // Wait for 1000 millisecond(s)
 }
};
Led led1(LED_PIN);
DiHelloWorld s1(led1);
void setup()
{
 led1.init();
}
void loop()
{
  s1.inOut(1, 2, 3);
}
 

fukurou

the supreme coder
ADMIN
C++:
// C++ code
//
class List {
public:
  byte length;
  byte data[16];
  void append(byte item) {
  if (length < 16) data[length++] = item;
 }
  void remove(byte index) {
  if (index >= length) return;
 memmove(&data[index], &data[index+1], length -
index - 1);
 length--;
 }
};
List l { .length = 3, .data = { 12, 82, 29 } };
void setup()
{
  l.remove(1);
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop()
{
  if (l.data[0] == 12){
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000); // Wait for 1000 millisecond(s)
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000); // Wait for 1000 millisecond(s)
  }
}
 

fukurou

the supreme coder
ADMIN
C++:
class Led{
 private:
 byte pin;
 public:
 Led(){this->pin = 13;}
 Led(byte pin){
 this->pin = pin;
 }
 void init(){
 pinMode(pin, OUTPUT);
 }
 void on(){
 digitalWrite(pin, HIGH);
 }
 void off(){
 digitalWrite(pin, LOW);
 }
};
class Skill {
    public:
    virtual void inOut() { Serial.println("A"); }
};

class DiHelloWorld : public Skill {
    private:
    Led _l1;
    public:
    DiHelloWorld(Led l1){_l1 = l1;_l1.init();}
    virtual void inOut() {
      // turn the LED on (HIGH is the voltage level)
 _l1.on();
 delay(1000); // Wait for 1000 millisecond(s)
 // turn the LED off by making the voltage LOW
 _l1.off();
 delay(1000); // Wait for 1000 millisecond(s)
     }
};


void setup() {
    // Skill* obj;    // base-class pointer

    Skill* s1 = new Skill();
    s1->inOut ();       // base class version
    Led led1(13);
    Skill* s2 = new DiHelloWorld(led1);
    s2->inOut ();
}

void loop() {
}

:s63:
 

fukurou

the supreme coder
ADMIN
C++:
class Led{
 private:
 byte pin;
 public:
 Led(){this->pin = 13;}
 Led(byte pin){
 this->pin = pin;
 }
 void init(){
 pinMode(pin, OUTPUT);
 }
 void on(){
 digitalWrite(pin, HIGH);
 }
 void off(){
 digitalWrite(pin, LOW);
 }
};
class Skill {
    public:
    virtual void inOut() { Serial.println("A"); }
};

class DiHelloWorld : public Skill {
    private:
    Led _l1;
    public:
    DiHelloWorld(Led l1){_l1 = l1;_l1.init();}
    virtual void inOut() {
      // turn the LED on (HIGH is the voltage level)
 _l1.on();
 delay(1000); // Wait for 1000 millisecond(s)
 // turn the LED off by making the voltage LOW
 _l1.off();
 delay(1000); // Wait for 1000 millisecond(s)
     }
};
// list of skills

class List {
public:
  byte length;
  Skill* data[16];
  void append(Skill* item) {
  if (length < 16) data[length++] = item;
 }
  void remove(byte index) {
  if (index >= length) return;
 memmove(&data[index], &data[index+1], length -
index - 1);
 length--;
 }
};

void setup() {
    // Skill* obj;    // base-class pointer

    Skill* s1 = new Skill();
    s1->inOut ();       // base class version
    Led led1(13);
    Skill* s2 = new DiHelloWorld(led1);
    s2->inOut ();
}

void loop() {
}
 

fukurou

the supreme coder
ADMIN
yes!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
it works!
C++:
class Led{
 private:
 byte pin;
 public:
 Led(){this->pin = 13;}
 Led(byte pin){
 this->pin = pin;
 }
 void init(){
 pinMode(pin, OUTPUT);
 }
 void on(){
 digitalWrite(pin, HIGH);
 }
 void off(){
 digitalWrite(pin, LOW);
 }
};
class Skill {
    public:
    virtual void inOut() { Serial.println("A"); }
};

class DiHelloWorld : public Skill {
    private:
    Led _l1;
    public:
    DiHelloWorld(Led l1){_l1 = l1;_l1.init();}
    virtual void inOut() {
      // turn the LED on (HIGH is the voltage level)
 _l1.on();
 delay(1000); // Wait for 1000 millisecond(s)
 // turn the LED off by making the voltage LOW
 _l1.off();
 delay(1000); // Wait for 1000 millisecond(s)
     }
};
// list of skills

class ListOfSkills {
public:
  byte length = 0;
  Skill* data[16];
  void append(Skill* item) {
  if (length < 16) data[length++] = item;
 }
  void remove(byte index) {
  if (index >= length) return;
 memmove(&data[index], &data[index+1], length -
index - 1);
 length--;
 }
};
// Chobit
class Chobit
{
private:
  ListOfSkills* dSkills = new ListOfSkills();
public:
  void addSkill(Skill* s1)
  {
    dSkills->append(s1);
  }
  void clearSkills()
  {
    dSkills = new ListOfSkills();
  }
  void think(byte ear, byte skin, byte eye)
  {
    for(int i=0;i<dSkills->length;i++)
    {
      dSkills->data[i]->inOut();
    }
  }
};
void setup() {
    // Skill* obj;    // base-class pointer

    // Skill* s1 = new Skill();
    // s1->inOut ();       // base class version
    Led led1(13);
    Skill* s2 = new DiHelloWorld(led1);
    // s2->inOut ();
    Chobit* c1 = new Chobit();
    c1->addSkill(s2);
    c1->think(0, 0, 0);
}

void loop() {
}

:s72::s72::s72::s72::s72:
 

fukurou

the supreme coder
ADMIN
documentation added : :s60:
C++:
// example Led class
class Led{
 private:
 byte pin;
 public:
 // c'tor
 Led(){this->pin = 13;}
 // c'tor with param
 Led(byte pin){
 this->pin = pin;
 }
 // cls methods
 void init(){
 pinMode(pin, OUTPUT);
 }
 void on(){
 digitalWrite(pin, HIGH);
 }
 void off(){
 digitalWrite(pin, LOW);
 }
};
// Skill super class
class Skill {
    public:
    Skill(){}
    virtual void inOut()
    {
      // override me
    }
};
// example hello world by blinking default Led #13 once
class DiHelloWorld : public Skill {
    private:
    Led _l1;
    public:
    DiHelloWorld(Led l1){_l1 = l1;_l1.init();}
    virtual void inOut() {
      // turn the LED on (HIGH is the voltage level)
 _l1.on();
 delay(1000); // Wait for 1000 millisecond(s)
 // turn the LED off by making the voltage LOW
 _l1.off();
 delay(1000); // Wait for 1000 millisecond(s)
     }
};
// list of Skill objects
// only the Chobit cls uses it
class ListOfSkills {
public:
  byte length = 0;
  Skill* data[16];
  void append(Skill* item) {
  if (length < 16) data[length++] = item;
 }
  void remove(byte index) {
  if (index >= length) return;
 memmove(&data[index], &data[index+1], length -
index - 1);
 length--;
 }
};
// Chobit
class Chobit
{
private:
  ListOfSkills* dSkills = new ListOfSkills();
public:
  void addSkill(Skill* s1)
  {
    dSkills->append(s1);
  }
  void clearSkills()
  {
    dSkills = new ListOfSkills();
  }
  // run all added skills
  void think(byte ear, byte skin, byte eye)
  {
    for(int i=0;i<dSkills->length;i++)
    {
      dSkills->data[i]->inOut();
    }
  }
};
void setup() {
    Led led1(13); // used to initialize the Hello World skill
    Skill* s2 = new DiHelloWorld(led1); // example skill created
    Chobit* c1 = new Chobit();
    c1->addSkill(s2);
    c1->think(0, 0, 0);
    c1->think(0, 0, 0);
}

void loop() {
}
 

owly

闇の伝説
Staff member
戦闘 コーダー
librarification:
LG: skill,listOfSkills,Chobit
DiHelloWorld: led,DiHelloWorld
 

fukurou

the supreme coder
ADMIN
C++:
#ifndef LivinGrimoireLight_H
#define LivinGrimoireLight_H
#include <Arduino.h>
// Skill super class
class Skill {
    public:
    Skill(){}
    virtual void inOut()
    {
      // override me
    }
};
// list of Skill objects
// only the Chobit cls uses it
class ListOfSkills {
public:
  byte length = 0;
  Skill* data[16];
  void append(Skill* item) {
  if (length < 16) data[length++] = item;
 }
  void remove(byte index) {
  if (index >= length) return;
 memmove(&data[index], &data[index+1], length -
index - 1);
 length--;
 }
};
// Chobit
class Chobit
{
private:
  ListOfSkills* dSkills = new ListOfSkills();
public:
  void addSkill(Skill* s1)
  {
    dSkills->append(s1);
  }
  void clearSkills()
  {
    dSkills = new ListOfSkills();
  }
  // run all added skills
  void think(byte ear, byte skin, byte eye)
  {
    for(int i=0;i<dSkills->length;i++)
    {
      dSkills->data[i]->inOut();
    }
  }
};
#endif

C++:
#ifndef DiHelloWorld_H
#define DiHelloWorld_H
// using Arduino hardware codes outside main:
#include <Arduino.h>
#include "LivinGrimoireLight.h"
class Led{
 private:
 byte pin;
 public:
 Led(){this->pin = 13;}
 Led(byte pin){
 this->pin = pin;
 }
 void init(){
 pinMode(pin, OUTPUT);
 }
 void on(){
 digitalWrite(pin, HIGH);
 }
 void off(){
 digitalWrite(pin, LOW);
 }
};
// example hello world by blinking default Led #13 once
class DiHelloWorld : public Skill {
    private:
    Led _l1;
    public:
    DiHelloWorld(Led l1){_l1 = l1;_l1.init();}
    virtual void inOut() {
      // turn the LED on (HIGH is the voltage level)
 _l1.on();
 delay(1000); // Wait for 1000 millisecond(s)
 // turn the LED off by making the voltage LOW
 _l1.off();
 delay(1000); // Wait for 1000 millisecond(s)
     }
};
#endif

C++:
#include "DiHelloWorld.h"
#include "LivinGrimoireLight.h"
void setup() {
    Led led1(13); // used to initialize the Hello World skill
    Skill* s2 = new DiHelloWorld(led1); // example skill created
    Chobit* c1 = new Chobit();
    c1->addSkill(s2);
    c1->think(0, 0, 0);
    c1->think(0, 0, 0);
}

void loop() {
}
 
Top