Moja konštrukcia RGB Laser DIY Scanner

Diallix

Člen
Registrovaný člen
Člen od
30 Sep 2020
Príspevkov
34
Reakčné skóre
73
Bodov
23
Paragraf (§)
Programátor
Trošku matematiky :]]

Podarilo sa mi implementovať vzorec pre výpočet súradnic X/Y vektorov pre rotáciu.
Po použití formule dôjde k úprave súradníc. Rozhodujúcim faktorom pri výpočte je uhol sínusu a cosinusu.

Implementovaný vzorec:
Musíte sa zaregistrovať, aby ste mohli vidieť obrázky


Videá rotácií priložím neskôr.


Celkovo navrhnutý ovládací software:
Musíte sa zaregistrovať, aby ste mohli vidieť obrázky




Niečo málo z vývoja:
Musíte sa zaregistrovať, aby ste mohli vidieť obrázky

Musíte sa zaregistrovať, aby ste mohli vidieť obrázky




Využitie celkovej kapacity MCU:
Musíte sa zaregistrovať, aby ste mohli vidieť obrázky
 

Diallix

Člen
Registrovaný člen
Člen od
30 Sep 2020
Príspevkov
34
Reakčné skóre
73
Bodov
23
Paragraf (§)
Programátor
Pridávam formulu algoritmu vykreslovania:

Musíte sa zaregistrovať, aby ste mohli vidieť obrázky
 

Diallix

Člen
Registrovaný člen
Člen od
30 Sep 2020
Príspevkov
34
Reakčné skóre
73
Bodov
23
Paragraf (§)
Programátor
Prikladám videá rotácií:

Ak chcete vidieť médiá, musíte sa zaregistrovať

Ak chcete vidieť médiá, musíte sa zaregistrovať
 

Diallix

Člen
Registrovaný člen
Člen od
30 Sep 2020
Príspevkov
34
Reakčné skóre
73
Bodov
23
Paragraf (§)
Programátor
Prikladám návrh služby riadenia algoritmov.
Ako asi vypadá jeden z mnohých modulov :]]


C:
#ifndef __CONFIG_DIALL_SET__
    #error "Current conf. path does not defined!"
#elif __CONFIG_DIALL_SET__ != 0xcbf29ce4
    #error "Changed token!. Rechange the token back!"
#endif

#if __NAMESPACE__ != 240640024
    #error "This Header does not support namespace! Use correct namespace for this processor."
#endif

#define __DRAWSERVICE_DIALL_SET__ 0xB54A7FA

#include "../EffectsConfig/EffectsConfig.h"
#include "../DrawObjects/DrawObjects.h"
#include "../DrawText/DrawText.h"

enum CircleMovingType
{
    CirclesMoving,
    PointsMoving
};

struct tagEFFECTSTEXT {
    ushort x;
    ushort y;
    ushort sizeFont;
    char * text;
    enum tagWAYTRACKING MovingType;
    int laserRed;
    int laserGreen;
    int laserBlue;
    bool start;
    int firstRun;
}EffectsText;

struct tagEFFECTSOBJECT {
    int size;
    int count;
    int delay;
    bool start;
    int firstRun;
};

struct tagEFFECTSSERVICE {
    int count;
    enum tagEFFECTS EffectType;
    bool start;
    int firstRun;
};

struct tagEFFECTSSERVICE EffectService;
struct tagEFFECTSSERVICE RunEffectsCustom;

struct tagEFFECTSOBJECT LineMovingEffects;
struct tagEFFECTSOBJECT CircleRotatingEffects;
struct tagEFFECTSOBJECT CircleMovingEffects;
struct tagEFFECTSOBJECT FishMovingEffects;
struct tagEFFECTSOBJECT ProgramCustomEffects;

PUBLIC void EffectsService(enum tagLASEREFFECTSTYPE LaserEffectsTyp);
PRIVATE void ShowTextEffect(void);
PRIVATE void LineMovingEffect(void);
PRIVATE void CircleRotatingEffect(void);
PRIVATE void CircleMovingEffect(enum CircleMovingType);
PRIVATE void FishMovingEffect(void);
PRIVATE void ChaosEffect(void);
PRIVATE void CustomEffect(void);
PRIVATE void RunEffects(enum tagEFFECTSTYPE);

PRIVATE void ShowTextEffect(void)
{
    if(EffectsText.start == true)
    {
        if(EffectsText.MovingType == Normal)
        {
            EffectsText.x = 20; //50;
        } else if(EffectsText.MovingType == Backward)
        {
            if (EffectsText.x <= GALVOLOW)
               {
                EffectsText.x = GALVOHIGH-1;
               } else EffectsText.x--;
        } else if(EffectsText.MovingType == Forward)
        {
            if (EffectsText.x >= GALVOHIGH-1)
               {
                EffectsText.x = GALVOLOW;
               } else EffectsText.x++;
        }
        VectorString(EffectsText.x, EffectsText.y, EffectsText.text, EffectsText.sizeFont, EffectsText.laserRed, EffectsText.laserGreen, EffectsText.laserBlue); 
    }
}

PRIVATE void LineMovingEffect(void)
{
    if(LineMovingEffects.start == true)
    {
        if((LineMovingEffects.count <= 1000 && LineMovingEffects.count < 2000) || (LineMovingEffects.count > 3000 && LineMovingEffects.count < 4000))
        {
            if(LineEffectsA.y > GALVOHIGH - 10)
            {
                LineEffectsA.y = 20;
                LineEffectsA.size = Randoming(20, GALVOHIGH - 1);
                LineEffectsA.speed = Randoming(10,13);
                LineEffectsA.LaserType = LaserColorsArray[Randoming(0, ARRAY_SIZE(LaserColorsArray))];
            } else LineEffectsA.y+=LineEffectsA.speed;
            DrawData(1,LineEffectsA.y);
            Delay(80);
            Line(1,LineEffectsA.y,LineEffectsA.size,LineEffectsA.y,LineEffectsA.LaserType);
            Delay(80);
        }
  
        if((LineMovingEffects.count >= 2000 && LineMovingEffects.count < 3000) || (LineMovingEffects.count > 4000 && LineMovingEffects.count < 5000))
        {
            if(LineEffectsB.y < 20)
            {
                LineEffectsB.y = GALVOHIGH - 1;
                LineEffectsB.size = Randoming(20, GALVOHIGH - 1);
                LineEffectsB.speed = Randoming(10,13);
                LineEffectsB.LaserType = LaserColorsArray[Randoming(0, ARRAY_SIZE(LaserColorsArray))];
            } else LineEffectsB.y-=LineEffectsB.speed;
            DrawData(1,LineEffectsB.y);
            Delay(80);
            Line(1,LineEffectsB.y,LineEffectsB.size,LineEffectsB.y,LineEffectsB.LaserType);
            Delay(80);
        }
  
        if((LineMovingEffects.count > 1000 && LineMovingEffects.count <= 3000) || (LineMovingEffects.count > 3000 && LineMovingEffects.count < 4000))
        { 
            if(LineEffectsC.x > GALVOHIGH - 10)
            {
                LineEffectsC.x = 20;
                LineEffectsC.size = Randoming(20, GALVOHIGH - 1);
                LineEffectsC.speed = Randoming(10,13);
                LineEffectsC.LaserType = LaserColorsArray[Randoming(0, ARRAY_SIZE(LaserColorsArray))];
            } else LineEffectsC.x+=LineEffectsC.speed;
            DrawData(LineEffectsC.x,1);
            Delay(80);
            Line(LineEffectsC.x,1,LineEffectsC.x,LineEffectsC.size,LineEffectsC.LaserType);
            Delay(80);
        }
  
        if((LineMovingEffects.count >= 2000 && LineMovingEffects.count < 4000) || (LineMovingEffects.count > 4000 && LineMovingEffects.count < 5000))
        {
            if(LineEffectsD.x < 20)
            {
                LineEffectsD.x = GALVOHIGH - 1;
                LineEffectsD.size = Randoming(20, GALVOHIGH - 1);
                LineEffectsD.speed = Randoming(10,13);
                LineEffectsD.LaserType = LaserColorsArray[Randoming(0, ARRAY_SIZE(LaserColorsArray))];
            } else LineEffectsD.x-=LineEffectsD.speed;
            DrawData(LineEffectsD.x,1);
            Delay(80);
            Line(LineEffectsD.x,1,LineEffectsD.x,LineEffectsD.size,LineEffectsD.LaserType);
            Delay(80);
        }
  
        if(LineMovingEffects.count == 5000)
        {
            LineMovingEffects.count = 0;
        } else LineMovingEffects.count++;

        Delay_ms(100);
    }
}

PRIVATE void CircleRotatingEffect(void)
{
    if(CircleRotatingEffects.start == true)
    { 
        CircleRotate(CircleRotatingEffects.count);
        if(CircleRotatingEffects.count < 220)
        {
            CircleRotatingEffects.count++;
        } else CircleRotatingEffects.count = 0; 
    }
}

PRIVATE void CircleMovingEffect(enum CircleMovingType type)
{
    if(CircleMovingEffects.start == true)
    {
        int size;

        if(type == CirclesMoving)
        {
            size = 15;
        } else if(type == PointsMoving)
        {
            size = 3;
        }

           if(CircleEffectsA.x >= GALVOHIGH - 1)
           {
            CircleEffectsA.y = Randoming(20, GALVOHIGH - 1);
            CircleEffectsA.x = 9;
            CircleEffectsA.LaserType = Red;
           } else CircleEffectsA.x+=2;
        Circle(CircleEffectsA.x,CircleEffectsA.y,size,4,CircleEffectsA.LaserType,0);

        if(CircleEffectsB.x >= GALVOHIGH - 1)
           {
            CircleEffectsB.y = Randoming(20, GALVOHIGH - 1);
            CircleEffectsB.x = 9;
            CircleEffectsB.LaserType = Green;
           } else CircleEffectsB.x+=3;
        Circle(CircleEffectsB.x,CircleEffectsB.y,size,4,CircleEffectsB.LaserType,0);

        if(CircleEffectsC.x >= GALVOHIGH - 1)
           {
            CircleEffectsC.y = Randoming(20, GALVOHIGH - 1);
            CircleEffectsC.x = 9;
            CircleEffectsC.LaserType = Blue;
           } else CircleEffectsC.x++;
        Circle(CircleEffectsC.x,CircleEffectsC.x,size,4,CircleEffectsC.LaserType,0);

           if(CircleEffectsD.x < 30)
           {
            CircleEffectsD.y = Randoming(20, GALVOHIGH - 1);
            CircleEffectsD.x = GALVOHIGH - 1;
            CircleEffectsD.LaserType = Random;
           } else CircleEffectsD.x--;
        Circle(CircleEffectsD.x,CircleEffectsD.x,size,4,CircleEffectsD.LaserType,1);
  
  
           if(CircleEffectsE.x < 30)
           {
            CircleEffectsE.y = Randoming(20, GALVOHIGH - 1);
            CircleEffectsE.x = GALVOHIGH - 1;
            CircleEffectsE.LaserType = Random;
           } else CircleEffectsE.x-=2;
        Circle(CircleEffectsE.x,CircleEffectsE.x,size,4,CircleEffectsE.LaserType, 2);
    } 
}

PRIVATE void FishMovingEffect(void)
{
    if(FishMovingEffects.start == true)
    {
           if(FishEffectsA.x >= GALVOHIGH - 1)
           {
            FishEffectsA.y = Randoming(20, GALVOHIGH - 1);
            FishEffectsA.x = 9;
            FishEffectsA.LaserType = Red;
           } else FishEffectsA.x+=2;
           FishL(FishEffectsA.x,FishEffectsA.y,3,FishEffectsA.LaserType);

        if(FishEffectsB.x >= GALVOHIGH - 1)
           {
            FishEffectsB.y = Randoming(20, GALVOHIGH - 1);
            FishEffectsB.x = 9;
            FishEffectsB.LaserType = Green;
           } else FishEffectsB.x++;
           FishL(FishEffectsB.x,FishEffectsB.y,2,FishEffectsB.LaserType);

        if(FishEffectsC.x >= GALVOHIGH - 1)
           {
            FishEffectsC.y = Randoming(20, GALVOHIGH - 1);
            FishEffectsC.x = 9;
            FishEffectsC.LaserType = Blue;
           } else FishEffectsC.x++;
           FishL(FishEffectsC.x,FishEffectsC.x,2,FishEffectsC.LaserType);

           if(FishEffectsD.x < 30)
           {
            FishEffectsD.x = Randoming(20, GALVOHIGH - 1);
            FishEffectsD.x = GALVOHIGH - 1;
            FishEffectsD.LaserType = Random;
           } else FishEffectsD.x--;
           FishR(FishEffectsD.x,FishEffectsD.x,3,FishEffectsD.LaserType,1);
  
           if(FishEffectsE.x < 30)
           {
            FishEffectsE.y = Randoming(20, GALVOHIGH - 1);
            FishEffectsE.x = GALVOHIGH - 1;
            FishEffectsE.LaserType = Random;
           } else FishEffectsE.x-=2;
           FishR(FishEffectsE.x,FishEffectsE.x,2,FishEffectsE.LaserType,2);
    } 
}

PRIVATE void CustomEffect(void)
{
    if(ProgramCustomEffects.start == true)
    {
        if(DeviceControl.Control.isCustomEffectsInstance1 == true)
        { 
            if(DeviceControl.Control.isCustomEffectsInstance1Changed == true)
            { 
                ProgramEffectsInstance1.laserRed = DeviceControl.Control.customEffectsInstance1RedLaser;
                ProgramEffectsInstance1.laserGreen = DeviceControl.Control.customEffectsInstance1GreenLaser;
                ProgramEffectsInstance1.laserBlue =  DeviceControl.Control.customEffectsInstance1BlueLaser;
                ProgramEffectsInstance1.size = DeviceControl.Control.customEffectsInstance1Size;
                ProgramEffectsInstance1.Rotating.isRotate = DeviceControl.Control.customEffectsInstance1Rotating;

                DeviceControl.Control.isCustomEffectsInstance1Changed = false;
            }
        
            if(DeviceControl.Control.customEffectsInstance1PositiOnX == 500)
            {
                   if(ProgramEffectsInstance1.x >= GALVOHIGH - 10)
                   {
                    ProgramEffectsInstance1.y = Randoming(20, GALVOHIGH - 10);
                    ProgramEffectsInstance1.x = 9;
                   } else     ProgramEffectsInstance1.x+=3;
            } else { ProgramEffectsInstance1.x = DeviceControl.Control.customEffectsInstance1PositiOnX-10; }

            if(DeviceControl.Control.customEffectsInstance1PositiOnY == 500)
            {
                if(ProgramEffectsInstance1.y >= GALVOHIGH - 10)
                   {
                    ProgramEffectsInstance1.x = Randoming(20, GALVOHIGH - 10);
                    ProgramEffectsInstance1.y = 9;
                   } else     ProgramEffectsInstance1.y+=3;
            } else { ProgramEffectsInstance1.y = DeviceControl.Control.customEffectsInstance1PositiOnY-10; }
               CustomProgramEffects(ProgramEffectsInstance1.x,ProgramEffectsInstance1.y, ProgramEffectsInstance1.size, ProgramEffectsInstance1.laserRed, ProgramEffectsInstance1.laserGreen, ProgramEffectsInstance1.laserBlue, ProgramEffectsInstance1.Rotating.isRotate, ProgramEffectsInstance1.Rotating.angle);     
          
            if(ProgramEffectsInstance1.Rotating.angle == ARRAY_SIZE(aucSinus)-1) ProgramEffectsInstance1.Rotating.angle = 0; else ProgramEffectsInstance1.Rotating.angle++;
        }

        if(DeviceControl.Control.isCustomEffectsInstance2 == true)
        {
            if(DeviceControl.Control.isCustomEffectsInstance2Changed == true)
            {
                ProgramEffectsInstance2.laserRed = DeviceControl.Control.customEffectsInstance2RedLaser;
                ProgramEffectsInstance2.laserGreen = DeviceControl.Control.customEffectsInstance2GreenLaser;
                ProgramEffectsInstance2.laserBlue =  DeviceControl.Control.customEffectsInstance2BlueLaser;
                ProgramEffectsInstance2.size = DeviceControl.Control.customEffectsInstance2Size;
                ProgramEffectsInstance2.Rotating.isRotate = DeviceControl.Control.customEffectsInstance2Rotating;
                DeviceControl.Control.isCustomEffectsInstance2Changed = false;
            }
        
            if(DeviceControl.Control.customEffectsInstance2PositiOnX == 500)
            {
                   if(ProgramEffectsInstance2.x >= GALVOHIGH - 10)
                   {
                    ProgramEffectsInstance2.y = Randoming(20, GALVOHIGH - 10);
                    ProgramEffectsInstance2.x = 9;
                   } else     ProgramEffectsInstance2.x+=4;
            } else { ProgramEffectsInstance2.x = DeviceControl.Control.customEffectsInstance2PositiOnX-10; }

            if(DeviceControl.Control.customEffectsInstance2PositiOnY == 500)
            {
                if(ProgramEffectsInstance2.y >= GALVOHIGH - 10)
                   {
                    ProgramEffectsInstance2.x = Randoming(20, GALVOHIGH - 10);
                    ProgramEffectsInstance2.y = 9;
                   } else     ProgramEffectsInstance2.y+=4;
            } else { ProgramEffectsInstance2.y = DeviceControl.Control.customEffectsInstance2PositiOnY-10; }
               CustomProgramEffects(ProgramEffectsInstance2.x,ProgramEffectsInstance2.y, ProgramEffectsInstance2.size, ProgramEffectsInstance2.laserRed, ProgramEffectsInstance2.laserGreen, ProgramEffectsInstance2.laserBlue, ProgramEffectsInstance2.Rotating.isRotate, ProgramEffectsInstance2.Rotating.angle);
          
            if(ProgramEffectsInstance2.Rotating.angle == ARRAY_SIZE(aucSinus)-1) ProgramEffectsInstance2.Rotating.angle = 0; else ProgramEffectsInstance2.Rotating.angle++;
        }

        if(DeviceControl.Control.isCustomEffectsInstance3 == true)
        {
            if(DeviceControl.Control.isCustomEffectsInstance3Changed == true)
            {
                ProgramEffectsInstance3.laserRed = DeviceControl.Control.customEffectsInstance3RedLaser;
                ProgramEffectsInstance3.laserGreen = DeviceControl.Control.customEffectsInstance3GreenLaser;
                ProgramEffectsInstance3.laserBlue =  DeviceControl.Control.customEffectsInstance3BlueLaser;
                ProgramEffectsInstance3.size = DeviceControl.Control.customEffectsInstance3Size;
                ProgramEffectsInstance3.x = DeviceControl.Control.customEffectsInstance2PositiOnX;
                ProgramEffectsInstance3.y = DeviceControl.Control.customEffectsInstance3PositiOnY;
                ProgramEffectsInstance3.Rotating.isRotate = DeviceControl.Control.customEffectsInstance3Rotating;
                DeviceControl.Control.isCustomEffectsInstance3Changed = false;
            }
        
            if(DeviceControl.Control.customEffectsInstance3PositiOnX == 500)
            {
                   if(ProgramEffectsInstance3.x >= GALVOHIGH - 10)
                   {
                    ProgramEffectsInstance3.y = Randoming(20, GALVOHIGH - 10);
                    ProgramEffectsInstance3.x = 9;
                   } else     ProgramEffectsInstance3.x+=4;
            } else { ProgramEffectsInstance3.x = DeviceControl.Control.customEffectsInstance2PositiOnY-10; }

            if(DeviceControl.Control.customEffectsInstance3PositiOnY == 500)
            {
                if(ProgramEffectsInstance3.y >= GALVOHIGH - 10)
                   {
                    ProgramEffectsInstance3.x = Randoming(20, GALVOHIGH - 10);
                    ProgramEffectsInstance3.y = 9;
                   } else     ProgramEffectsInstance3.y+=4;
            } else { ProgramEffectsInstance3.y = DeviceControl.Control.customEffectsInstance3PositiOnY-10; }
               CustomProgramEffects(ProgramEffectsInstance3.x,ProgramEffectsInstance3.y, ProgramEffectsInstance3.size, ProgramEffectsInstance3.laserRed, ProgramEffectsInstance3.laserGreen, ProgramEffectsInstance3.laserBlue, ProgramEffectsInstance3.Rotating.isRotate, ProgramEffectsInstance3.Rotating.angle);
          
            if(ProgramEffectsInstance3.Rotating.angle == ARRAY_SIZE(aucSinus)-1) ProgramEffectsInstance3.Rotating.angle = 0; else ProgramEffectsInstance3.Rotating.angle++;
        }
    } 
}

PRIVATE void ChaosEffect(void)
{
    if(LaserTimer.timerCounter == LaserTimer.timer)
    {
        LaserControl(ChaosRandom, LaserDeviceEffects, null, null, null, ON);
        LaserTimer.timerCounter = 0;
    }
    LaserTimer.timerCounter++;

    float valueX = Randoming(5,GALVOHIGH - 1);
    float valueY = Randoming(5,GALVOHIGH - 1);

    DrawData(valueX, valueY);
    Delay_ms(100);
}

PRIVATE void RunEffects(enum tagEFFECTSTYPE type)
{
    if(!RunEffectsCustom.firstRun || (DeviceControl.Control.programEffectType == -1 && RunEffectsCustom.EffectType == Disable))
    {
        if(type == DeviceEffects)
        {
            RunEffectsCustom.EffectType = aucEffectsArray[Randoming(0, ARRAY_SIZE(aucEffectsArray))];
        } else
        {
            RunEffectsCustom.EffectType = Disable;
        }

        RunEffectsCustom.count = 0;

        RunEffectsCustom.start = true;
        RunEffectsCustom.firstRun = 1;
    }

    if(!LineMovingEffects.firstRun)
    {
        LineEffectsA.y = 20;
        LineEffectsB.y = GALVOHIGH - 1;;
        LineEffectsC.x = 20;
        LineEffectsD.x = GALVOHIGH - 1;
        LineEffectsA.speed = 5;
        LineEffectsB.speed = 5;
        LineEffectsC.speed = 5;
        LineEffectsD.speed = 5;
        LineMovingEffects.count = 0;
        LineMovingEffects.start = true;
        LineMovingEffects.firstRun = 1;
    }
    if(!CircleRotatingEffects.firstRun)
    {
        CircleRotatingEffects.delay = 250;
        CircleRotatingEffects.count = 0;
        CircleRotatingEffects.start = true;
         CircleRotatingEffects.firstRun = 1;
    }
    if(!CircleMovingEffects.firstRun)
    {
        CircleEffectsA.x = 9;
        CircleEffectsB.x = 9;
        CircleEffectsC.x = 9;
        CircleEffectsD.x = 230;
        CircleEffectsE.x = 230;
        CircleMovingEffects.start = true;
        CircleMovingEffects.firstRun = 1;
    }
    if(!FishMovingEffects.firstRun)
    {
        FishEffectsA.x = 9;
        FishEffectsB.x = 9;
        FishEffectsC.x = 9;
        FishEffectsD.x = 230;
        FishEffectsE.x = 230;
        FishMovingEffects.start = true;
        FishMovingEffects.firstRun = 1;
    }
    

    if(RunEffectsCustom.start == true)
     {
        if(RunEffectsCustom.EffectType == LineMoving  || DeviceControl.Control.programEffectType == 4)
        {
            LineMovingEffect();
        }
        if(RunEffectsCustom.EffectType == CircleRotating || DeviceControl.Control.programEffectType == 5)
        {
            CircleRotatingEffect();
        }
        if(RunEffectsCustom.EffectType == CircleMoving || DeviceControl.Control.programEffectType == 3)
        {
            CircleMovingEffect(CirclesMoving);
        }
        if(RunEffectsCustom.EffectType == FishMoving || DeviceControl.Control.programEffectType == 2)
        {
            FishMovingEffect();
         }
        if(RunEffectsCustom.EffectType == xxx|| DeviceControl.Control.programEffectType == 1)
        {
        }
        if(RunEffectsCustom.EffectType == Chaos || DeviceControl.Control.programEffectType == 6)
        {
            ChaosEffect();
        }
        if(RunEffectsCustom.EffectType == PointMoving || DeviceControl.Control.programEffectType == 7)
        {
            CircleMovingEffect(PointsMoving);;
        } 
        if(((RunEffectsCustom.count == -1 ||
             RunEffectsCustom.EffectType == LineMoving || DeviceControl.Control.programEffectType == 4) && RunEffectsCustom.count == 5000)    ||
           ((RunEffectsCustom.EffectType == CircleRotating || DeviceControl.Control.programEffectType == 5) && RunEffectsCustom.count == 220) ||
           ((RunEffectsCustom.EffectType == CircleMoving || DeviceControl.Control.programEffectType == 3) && RunEffectsCustom.count == 400)   ||
           ((RunEffectsCustom.EffectType == FishMoving || DeviceControl.Control.programEffectType == 2) && RunEffectsCustom.count == 600)     ||
           ((RunEffectsCustom.EffectType == xxx || DeviceControl.Control.programEffectType == 1) && RunEffectsCustom.count == 400)      ||
           ((RunEffectsCustom.EffectType == Chaos || DeviceControl.Control.programEffectType == 6) && RunEffectsCustom.count == 1000)         ||
           ((RunEffectsCustom.EffectType == PointMoving || DeviceControl.Control.programEffectType == 7) && RunEffectsCustom.count == 400) 
          )
        {
            if(type == DeviceEffects)
            {
                RunEffectsCustom.EffectType = aucEffectsArray[Randoming(0, ARRAY_SIZE(aucEffectsArray))];
                DeviceControl.Control.programEffectType = -1;
            } else
            {
                RunEffectsCustom.EffectType = Disable;
            }
            RunEffectsCustom.count = 0;
        } else
        {
            RunEffectsCustom.count++;
        }
      }
}

PUBLIC void EffectsService(enum tagLASEREFFECTSTYPE LaserEffectsType)
{
    if(!EffectService.firstRun)
    {
        EffectService.start = true;
        EffectService.firstRun = 1;
    }

    if(EffectService.start == true)
    {
        if(LaserEffectsType == LaserMicEffects)
        {
            if(LaserTimer.timerCounter == LaserTimer.timer)
            {
                LaserControl(ChaosRandom, LaserMicEffects, null, null, null, ON);
                LaserTimer.timerCounter = 0;
            }
            LaserTimer.timerCounter++;
          
            return;
        }

        if((DeviceControl.Control.isDeviceConnected == false && SW.Mode.modeRandom == 1) || (DeviceControl.Control.isDeviceConnected == true && (DeviceControl.Control.isDeviceCustomEffects == true || DeviceControl.Control.isDeviceRandommingEffects == true)))
        {
            if((LaserEffectsType == LaserDeviceEffects && DeviceControl.Control.isDeviceRandommingEffects == true) || (DeviceControl.Control.isDeviceConnected == false && SW.Mode.modeRandom == 1))
            {
                RunEffects(DeviceEffects);
  
                return;
            } else if(DeviceControl.Control.isDeviceCustomEffects == true && DeviceControl.Control.isDeviceRandommingEffects == false)
            {
                if(LaserEffectsType == LaserCustomEffects)
                {
                    if(DeviceControl.Control.isCustomEffectsLasers == true)
                    {
                        LaserControl(Red, LaserCustomEffects, null,null,null, ON);
                        LaserControl(Green, LaserCustomEffects, null,null,null, ON);
                        LaserControl(Blue, LaserCustomEffects, null,null,null, ON);
  
                        return;
                    } else
  
                    if(DeviceControl.Control.isCustomEffectsInstance1 == true || DeviceControl.Control.isCustomEffectsInstance2 == true || DeviceControl.Control.isCustomEffectsInstance3 == true)
                    {
                        if(!ProgramCustomEffects.firstRun)
                        {
                            ProgramEffectsInstance1.x = 0;
                            ProgramEffectsInstance1.y = 0;
                            ProgramEffectsInstance1.size = 4;
                            ProgramEffectsInstance1.Rotating.angle = 0;
                            ProgramEffectsInstance2.x = 0;
                            ProgramEffectsInstance2.y = 0;
                            ProgramEffectsInstance2.size = 4;
                            ProgramEffectsInstance2.Rotating.angle = 0;
                            ProgramEffectsInstance3.x = 0;
                            ProgramEffectsInstance3.y= 0;
                            ProgramEffectsInstance3.size = 4;
                            ProgramEffectsInstance3.Rotating.angle = 0;
                            ProgramCustomEffects.start = true;
                            ProgramCustomEffects.firstRun = 1;
                        }
  
                        CustomEffect();
  
                        return;
                    } else
  
                    if(DeviceControl.Control.isCustomEffectsProgramEffectsChange == true && DeviceControl.Control.isDeviceCustomEffects == true)
                    {
                        RunEffectsCustom.EffectType = Disable;
                        RunEffects(ProgramEffects);
  
                        return;
                    } else
  
                    if(DeviceControl.Control.isCustomEffectsTextEffectsReady == true)
                    {
                        if(!EffectsText.firstRun)
                        {
                            EffectsText.x = 20;//50;
                            EffectsText.y = 160;//60;
                            EffectsText.sizeFont = 4;
                            EffectsText.laserRed = LASERHIGH;
                            EffectsText.laserGreen = LASERLOW;
                            EffectsText.laserBlue = LASERLOW;
                            EffectsText.MovingType = None;
                            EffectsText.start = true;
                            EffectsText.firstRun = 1;
                        }
          
                        if(DeviceControl.Control.isCustomEffectsTextEffectsSizeChange == true && DeviceControl.Control.isCustomEffectsProgramEffectsChange == false)
                        {
                            EffectsText.sizeFont = DeviceControl.Control.customEffectsTextContentSize;
                            DeviceControl.Control.isCustomEffectsTextEffectsSizeChange = false;
                        }
                        if(DeviceControl.Control.isCustomEffectsTextEffectsMoveChange == true)
                        {
                            EffectsText.MovingType = DeviceControl.Control.CustomEffectsTextContentMoveType;
                            DeviceControl.Control.isCustomEffectsTextEffectsMoveChange = false;
                        }
                        if(DeviceControl.Control.isCustomEffectsTextEffectsColorChange == true)
                        {
                            EffectsText.laserRed = DeviceControl.Control.customEffectsTextRedLaserLight;
                            EffectsText.laserGreen = DeviceControl.Control.customEffectsTextGreenLaserLight;
                            EffectsText.laserBlue = DeviceControl.Control.customEffectsTextBlueLaserLight;
                            DeviceControl.Control.isCustomEffectsTextEffectsColorChange = false;
                        }
          
                        char text[10];
                        strcpy(text, DeviceControl.Control.customEffectsTextContent);
  
                        ReadText(text);
                        EffectsText.text = text;
          
                        ShowTextEffect();
      
                        return;
                    }
                }
            }
        }
    } else     
    { 
        LaserControl(Red, LaserEffectsType, null, null, null, OFF);
        LaserControl(Green, LaserEffectsType, null, null, null, OFF);
        LaserControl(Blue, LaserEffectsType, null, null, null, OFF);
    }
}

#ifndef _Diall_
    #define _Diall_ 0xac2f01
    #warning "Created by Diallix, Diallix Software (C)"
#endif
 
Naposledy upravené:

Rami6711

Aktívny člen
Registrovaný člen
Člen od
13 Apr 2021
Príspevkov
387
Reakčné skóre
496
Bodov
33
Paragraf (§)
§23 (SK) / §7 (CZ)
Joj, to by bol dlhy zoznam "MISRA rules" :cool:
 

Diallix

Člen
Registrovaný člen
Člen od
30 Sep 2020
Príspevkov
34
Reakčné skóre
73
Bodov
23
Paragraf (§)
Programátor
Ahojte. Riešim krabičku :]] cez hmlu a v noci som projektoval, a je to fakt krása. Budem vyrábať krabičku :]] i keď neviem ako - ide na milimetre, ale dám to a vy sa máte na čo tešiť :]]
 
ElektroLab.eu

Reklama

Paul's Electronics

Podporte nás

Vyhľadaj komponenty

Nové príspevky

Reklamný blok

Hľadáte lacný multimeter?
Top