Esempio n. 1
0
        public override void SetFanConstants(FanConstValues.FanType fanType)
        {
            var eepromMapping1 = new EEPROMMapping(m_oBootloaderConnection.ReadAllReadableEEPROM(), MyPrinterProfile.EEPROMConstants);
            var alignedByte1   = (int)eepromMapping1.GetAlignedByte("FANTYPE");
            var alignedByte2   = eepromMapping1.GetAlignedByte("FANOFFSET");
            var num1           = eepromMapping1.GetFloat("FANSCALE");

            FanConstValues.FanValues fanConstant = FanConstValues.FanConstants[fanType];
            var num2 = (int)(byte)fanType;

            if (alignedByte1 != num2)
            {
                m_oBootloaderConnection.WriteToEEPROM(GetEEPROMDataLocation("FANTYPE"), eepromMapping1.AlignedByteToBytaArray((ushort)fanType));
            }

            if (alignedByte2 != fanConstant.Offset)
            {
                m_oBootloaderConnection.WriteToEEPROM(GetEEPROMDataLocation("FANOFFSET"), eepromMapping1.AlignedByteToBytaArray((ushort)fanConstant.Offset));
            }

            if (num1 != (double)fanConstant.Scale)
            {
                m_oBootloaderConnection.WriteToEEPROM(GetEEPROMDataLocation("FANSCALE"), BitConverter.GetBytes(fanConstant.Scale));
            }

            var eepromMapping2 = new EEPROMMapping(m_oBootloaderConnection.ReadAllReadableEEPROM(), MyPrinterProfile.EEPROMConstants);
            var alignedByte3   = (int)eepromMapping1.GetAlignedByte("FANTYPE");
            var alignedByte4   = eepromMapping1.GetAlignedByte("FANOFFSET");
            var num3           = eepromMapping1.GetFloat("FANSCALE");
            var num4           = (int)(byte)fanType;

            if (alignedByte3 == num4 && alignedByte4 == fanConstant.Offset && num3 == (double)fanConstant.Scale)
            {
                WriteLog(">> ok", Logger.TextType.Read);
            }
            else
            {
                WriteLog(">> failed", Logger.TextType.Read);
            }
        }
Esempio n. 2
0
        private void CheckFirmwareStep()
        {
            foreach (KeyValuePair <char, FirmwareDetails> firmware in MyPrinterProfile.ProductConstants.FirmwareList)
            {
                var             key             = firmware.Key;
                FirmwareDetails firmwareDetails = firmware.Value;
                if (mInterfaceVersion == BootloaderController.BootloaderInterfaceVersion.V2)
                {
                    SetBootloader(key);
                }

                var eepromMapping = new EEPROMMapping(m_oBootloaderConnection.ReadAllReadableEEPROM(), MyPrinterProfile.EEPROMConstants);
                var uint32_1      = eepromMapping.GetUInt32("FirmwareVersion");
                var uint32_2      = eepromMapping.GetUInt32("FirmwareCRC");
                BootloaderController.FirmwareStatus firmwareStatus = BootloadCheckFirmware(firmwareDetails, uint32_1, uint32_2);
                if (mCheckedFirmwareStatus.ContainsKey(key))
                {
                    mCheckedFirmwareStatus[key] = firmwareStatus;
                }
                else
                {
                    mCheckedFirmwareStatus.Add(key, firmwareStatus);
                }
            }
            var bFirmwareIsInvalid = false;

            foreach (KeyValuePair <char, BootloaderController.FirmwareStatus> checkedFirmwareStatu in mCheckedFirmwareStatus)
            {
                if (BootloaderController.FirmwareStatus.Bad == checkedFirmwareStatu.Value)
                {
                    bFirmwareIsInvalid = true;
                    break;
                }
            }
            SetNextActionFromFirmwareStatus(bFirmwareIsInvalid);
        }
Esempio n. 3
0
        public static void M580SetBackLashSpeed(GCode gcode, FirmwareController connection)
        {
            connection.SetBacklashSpeed(gcode.X);
            EepromAddressInfo eepromInfo = connection.MyPrinterProfile.EEPROMConstants.GetEepromInfo("BacklashSpeed");
            var num = (int)connection.WriteManualCommands("M618 S" + eepromInfo.EepromAddr + " P" + EEPROMMapping.FloatToBinaryInt(gcode.X) + " T" + eepromInfo.Size);

            StandardVirtualCodes.SendOK(connection);
        }
Esempio n. 4
0
        public static void M571SetBacklashConstants(GCode gcode, FirmwareController connection)
        {
            EepromAddressInfo eepromInfo1 = connection.MyPrinterProfile.EEPROMConstants.GetEepromInfo("BacklashX");
            EepromAddressInfo eepromInfo2 = connection.MyPrinterProfile.EEPROMConstants.GetEepromInfo("BacklashY");

            connection.SetBacklash(gcode.X, gcode.Y);
            var num1 = (int)connection.WriteManualCommands("M618 S" + eepromInfo1.EepromAddr + " P" + EEPROMMapping.FloatToBinaryInt(gcode.X) + " T" + eepromInfo1.Size);
            var num2 = (int)connection.WriteManualCommands("M618 S" + eepromInfo2.EepromAddr + " P" + EEPROMMapping.FloatToBinaryInt(gcode.Y) + " T" + eepromInfo2.Size);

            StandardVirtualCodes.SendOK(connection);
        }
Esempio n. 5
0
        public static void M682SetLimitingSpeed(GCode gcode, FirmwareController connection)
        {
            EepromAddressInfo eepromInfo1 = connection.MyPrinterProfile.EEPROMConstants.GetEepromInfo("SpeedLimitX");
            EepromAddressInfo eepromInfo2 = connection.MyPrinterProfile.EEPROMConstants.GetEepromInfo("SpeedLimitY");
            EepromAddressInfo eepromInfo3 = connection.MyPrinterProfile.EEPROMConstants.GetEepromInfo("SpeedLimitZ");
            EepromAddressInfo eepromInfo4 = connection.MyPrinterProfile.EEPROMConstants.GetEepromInfo("SpeedLimitEp");
            EepromAddressInfo eepromInfo5 = connection.MyPrinterProfile.EEPROMConstants.GetEepromInfo("SpeedLimitEn");

            if (gcode.HasX)
            {
                var num1 = (int)connection.WriteManualCommands("M618 S" + (int)eepromInfo1.EepromAddr + " P" + EEPROMMapping.FloatToBinaryInt(gcode.X) + " T" + eepromInfo1.Size);
            }
            if (gcode.HasY)
            {
                var num2 = (int)connection.WriteManualCommands("M618 S" + (int)eepromInfo2.EepromAddr + " P" + EEPROMMapping.FloatToBinaryInt(gcode.Y) + " T" + eepromInfo2.Size);
            }
            if (gcode.HasZ)
            {
                var num3 = (int)connection.WriteManualCommands("M618 S" + (int)eepromInfo3.EepromAddr + " P" + EEPROMMapping.FloatToBinaryInt(gcode.Z) + " T" + eepromInfo3.Size);
            }
            if (gcode.HasE)
            {
                var num4 = (int)connection.WriteManualCommands("M618 S" + (int)eepromInfo4.EepromAddr + " P" + EEPROMMapping.FloatToBinaryInt(gcode.E) + " T" + eepromInfo4.Size);
            }
            if (gcode.HasR)
            {
                var num5 = (int)connection.WriteManualCommands("M618 S" + (int)eepromInfo5.EepromAddr + " P" + EEPROMMapping.FloatToBinaryInt(gcode.R) + " T" + eepromInfo5.Size);
            }
            StandardVirtualCodes.SendOK(connection);
        }
Esempio n. 6
0
        private void BootLoaderStartup()
        {
            FirmwareDetails firmware = MyPrinterProfile.ProductConstants.FirmwareList['M'];

            if (mInterfaceVersion == BootloaderController.BootloaderInterfaceVersion.V2)
            {
                SetBootloader('M');
            }

            MyPrinterInfo.hardware.machine_type = "The_Micro";
            var eepromMapping = new EEPROMMapping(m_oBootloaderConnection.ReadAllReadableEEPROM(), MyPrinterProfile.EEPROMConstants);
            var flag          = false;
            var str           = "";

            byte[] bytesFromLocation = eepromMapping.GetBytesFromLocation("SerialNumber", 16);
            for (var index = 0; index < 16; ++index)
            {
                if (bytesFromLocation[index] == byte.MaxValue)
                {
                    flag = true;
                }

                str += ((char)bytesFromLocation[index]).ToString();
            }
            if (flag)
            {
                BroadcastServer.BroadcastMessage(new SpoolerMessage(MessageType.UserDefined, MySerialNumber, "There was a major error in your printer. Please reset the printer. If the problem persist, contact M3D.").Serialize());
                Status = PrinterStatus.Error_PrinterNotAlive;
            }
            else
            {
                MySerialNumber = new PrinterSerialNumber(str);
                foreach (IFirstRunUpdater updater in MyPrinterProfile.FirstRunConstants.updater_list)
                {
                    updater.CheckForUpdate(str, eepromMapping.GetAllEEPROMData(), m_oBootloaderConnection, MyPrinterProfile);
                }

                logger.ResetWithSerialNumber(MySerialNumber.ToString());
                LoadPersistantData();
                PersistantDetails.hours_used     = eepromMapping.GetFloat("HoursCounterSpooler");
                HardwareDetails.firmware_version = eepromMapping.GetUInt32("FirmwareVersion");
                PersistantData.RestartOptions restartOptions = PersistantDetails.PopRestartAction();
                SavePersistantData();
                CurrentBootloaderStep = BootloaderController.BootLoaderStep.CheckFirmware;
                if (restartOptions.RestartAction == PersistantData.RestartAction.SetExtruderCurrent)
                {
                    SetExtruderCurrent((ushort)restartOptions.RestartActionParam);
                }
                else if (restartOptions.RestartAction == PersistantData.RestartAction.SetFan)
                {
                    SetFanConstants((FanConstValues.FanType)restartOptions.RestartActionParam);
                }
                else if (restartOptions.RestartAction == PersistantData.RestartAction.ForceStayBootloader)
                {
                    Status = PrinterStatus.Bootloader_Ready;
                    CurrentBootloaderStep = BootloaderController.BootLoaderStep.Waiting;
                }
                else
                {
                    if (restartOptions.RestartAction != PersistantData.RestartAction.ForceUpdateFirmware)
                    {
                        return;
                    }

                    CurrentBootloaderStep = BootloaderController.BootLoaderStep.ForceFirmwareUpdate;
                }
            }
        }