Added old firmware and pcb design files

These are all design documents that I thought I had lost. It's may make
me cringe, but it's still cool to use it to see how far I've come.
This commit is contained in:
2016-05-12 20:04:43 -07:00
parent a4df0d921d
commit b300c76103
1047 changed files with 379298 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=C:\Users\Corwin\AppData\Roaming\Insync\App\res\shared-folder-vista-7.ico,0

View File

@@ -0,0 +1,179 @@
#include "qextserialport.h"
#include "qextserialenumerator.h"
#include "dialog.h"
#include "ui_dialog.h"
#include <QtCore>
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
//! [0]
foreach (QextPortInfo info, QextSerialEnumerator::getPorts())
ui->portBox->addItem(info.portName);
//make sure user can input their own port name!
ui->portBox->setEditable(true);
ui->baudRateBox->addItem("1200", BAUD1200);
ui->baudRateBox->addItem("2400", BAUD2400);
ui->baudRateBox->addItem("4800", BAUD4800);
ui->baudRateBox->addItem("9600", BAUD9600);
ui->baudRateBox->addItem("19200", BAUD19200);
ui->baudRateBox->setCurrentIndex(3);
ui->parityBox->addItem("NONE", PAR_NONE);
ui->parityBox->addItem("ODD", PAR_ODD);
ui->parityBox->addItem("EVEN", PAR_EVEN);
ui->dataBitsBox->addItem("5", DATA_5);
ui->dataBitsBox->addItem("6", DATA_6);
ui->dataBitsBox->addItem("7", DATA_7);
ui->dataBitsBox->addItem("8", DATA_8);
ui->dataBitsBox->setCurrentIndex(3);
ui->stopBitsBox->addItem("1", STOP_1);
ui->stopBitsBox->addItem("2", STOP_2);
ui->queryModeBox->addItem("Polling", QextSerialPort::Polling);
ui->queryModeBox->addItem("EventDriven", QextSerialPort::EventDriven);
//! [0]
ui->led->turnOff();
timer = new QTimer(this);
timer->setInterval(40);
//! [1]
PortSettings settings = {BAUD9600, DATA_8, PAR_NONE, STOP_1, FLOW_OFF, 10};
port = new QextSerialPort(ui->portBox->currentText(), settings, QextSerialPort::Polling);
//! [1]
enumerator = new QextSerialEnumerator(this);
enumerator->setUpNotifications();
connect(ui->baudRateBox, SIGNAL(currentIndexChanged(int)), SLOT(onBaudRateChanged(int)));
connect(ui->parityBox, SIGNAL(currentIndexChanged(int)), SLOT(onParityChanged(int)));
connect(ui->dataBitsBox, SIGNAL(currentIndexChanged(int)), SLOT(onDataBitsChanged(int)));
connect(ui->stopBitsBox, SIGNAL(currentIndexChanged(int)), SLOT(onStopBitsChanged(int)));
connect(ui->queryModeBox, SIGNAL(currentIndexChanged(int)), SLOT(onQueryModeChanged(int)));
connect(ui->timeoutBox, SIGNAL(valueChanged(int)), SLOT(onTimeoutChanged(int)));
connect(ui->portBox, SIGNAL(editTextChanged(QString)), SLOT(onPortNameChanged(QString)));
connect(ui->openCloseButton, SIGNAL(clicked()), SLOT(onOpenCloseButtonClicked()));
connect(ui->sendButton, SIGNAL(clicked()), SLOT(onSendButtonClicked()));
connect(timer, SIGNAL(timeout()), SLOT(onReadyRead()));
connect(port, SIGNAL(readyRead()), SLOT(onReadyRead()));
connect(enumerator, SIGNAL(deviceDiscovered(QextPortInfo)), SLOT(onPortAddedOrRemoved()));
connect(enumerator, SIGNAL(deviceRemoved(QextPortInfo)), SLOT(onPortAddedOrRemoved()));
setWindowTitle(tr("QextSerialPort Demo"));
}
Dialog::~Dialog()
{
delete ui;
delete port;
}
void Dialog::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void Dialog::onPortNameChanged(const QString & /*name*/)
{
if (port->isOpen()) {
port->close();
ui->led->turnOff();
}
}
//! [2]
void Dialog::onBaudRateChanged(int idx)
{
port->setBaudRate((BaudRateType)ui->baudRateBox->itemData(idx).toInt());
}
void Dialog::onParityChanged(int idx)
{
port->setParity((ParityType)ui->parityBox->itemData(idx).toInt());
}
void Dialog::onDataBitsChanged(int idx)
{
port->setDataBits((DataBitsType)ui->dataBitsBox->itemData(idx).toInt());
}
void Dialog::onStopBitsChanged(int idx)
{
port->setStopBits((StopBitsType)ui->stopBitsBox->itemData(idx).toInt());
}
void Dialog::onQueryModeChanged(int idx)
{
port->setQueryMode((QextSerialPort::QueryMode)ui->queryModeBox->itemData(idx).toInt());
}
void Dialog::onTimeoutChanged(int val)
{
port->setTimeout(val);
}
//! [2]
//! [3]
void Dialog::onOpenCloseButtonClicked()
{
if (!port->isOpen()) {
port->setPortName(ui->portBox->currentText());
port->open(QIODevice::ReadWrite);
}
else {
port->close();
}
//If using polling mode, we need a QTimer
if (port->isOpen() && port->queryMode() == QextSerialPort::Polling)
timer->start();
else
timer->stop();
//update led's status
ui->led->turnOn(port->isOpen());
}
//! [3]
//! [4]
void Dialog::onSendButtonClicked()
{
if (port->isOpen() && !ui->sendEdit->toPlainText().isEmpty())
port->write(ui->sendEdit->toPlainText().toLatin1());
}
void Dialog::onReadyRead()
{
if (port->bytesAvailable()) {
ui->recvEdit->moveCursor(QTextCursor::End);
ui->recvEdit->insertPlainText(QString::fromLatin1(port->readAll()));
}
}
void Dialog::onPortAddedOrRemoved()
{
QString current = ui->portBox->currentText();
ui->portBox->blockSignals(true);
ui->portBox->clear();
foreach (QextPortInfo info, QextSerialEnumerator::getPorts())
ui->portBox->addItem(info.portName);
ui->portBox->setCurrentIndex(ui->portBox->findText(current));
ui->portBox->blockSignals(false);
}
//! [4]

View File

@@ -0,0 +1,45 @@
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
namespace Ui {
class Dialog;
}
class QTimer;
class QextSerialPort;
class QextSerialEnumerator;
class Dialog : public QDialog
{
Q_OBJECT
public:
explicit Dialog(QWidget *parent = 0);
~Dialog();
protected:
void changeEvent(QEvent *e);
private Q_SLOTS:
void onPortNameChanged(const QString &name);
void onBaudRateChanged(int idx);
void onParityChanged(int idx);
void onDataBitsChanged(int idx);
void onStopBitsChanged(int idx);
void onQueryModeChanged(int idx);
void onTimeoutChanged(int val);
void onOpenCloseButtonClicked();
void onSendButtonClicked();
void onReadyRead();
void onPortAddedOrRemoved();
private:
Ui::Dialog *ui;
QTimer *timer;
QextSerialPort *port;
QextSerialEnumerator *enumerator;
};
#endif // DIALOG_H

View File

@@ -0,0 +1,191 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>604</width>
<height>485</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout" stretch="3,1">
<item>
<widget class="QPlainTextEdit" name="recvEdit">
<property name="maximumBlockCount">
<number>800</number>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="sendEdit"/>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Port:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="portBox"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>BaudRate:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="baudRateBox"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>DataBits:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="dataBitsBox"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Parity:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="parityBox"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>StopBits:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="stopBitsBox"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>QueryMode:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="queryModeBox"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Timeout:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="timeoutBox">
<property name="suffix">
<string> ms</string>
</property>
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
<property name="value">
<number>10</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="HLed" name="led" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>25</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="openCloseButton">
<property name="text">
<string>Open/Close</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="sendButton">
<property name="text">
<string>Send</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>HLed</class>
<extends>QWidget</extends>
<header>hled.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,133 @@
#include <QtGui>
#include "hled.h"
struct HLed::Private
{
public:
Private()
: darkerFactor(300), color(Qt::green), isOn(true)
{ }
int darkerFactor;
QColor color;
bool isOn;
};
HLed::HLed(QWidget *parent)
:QWidget(parent), m_d(new Private)
{
}
HLed::~HLed()
{
delete m_d;
}
QColor HLed::color() const
{
return m_d->color;
}
void HLed::setColor(const QColor &color)
{
if (m_d->color == color)
return;
update();
}
QSize HLed::sizeHint() const
{
return QSize(20, 20);
}
QSize HLed::minimumSizeHint() const
{
return QSize(16, 16);
}
void HLed::toggle()
{
m_d->isOn = !m_d->isOn;
update();
}
void HLed::turnOn(bool on)
{
m_d->isOn = on;
update();
}
void HLed::turnOff(bool off)
{
turnOn(!off);
}
void HLed::paintEvent(QPaintEvent * /*event*/)
{
int width = ledWidth();
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
QColor color = m_d->isOn ? m_d->color
: m_d->color.darker(m_d->darkerFactor);
QBrush brush;
brush.setStyle(Qt::SolidPattern);
brush.setColor(color);
painter.setBrush(brush);
// draw plain
painter.drawEllipse(1, 1, width-1, width-1);
QPen pen;
pen.setWidth(2);
int pos = width / 5 + 1;
int lightWidth = width * 2 / 3;
int lightQuote = 130 * 2 / (lightWidth ? lightWidth : 1) + 100;
// draw bright spot
while (lightWidth) {
color = color.lighter(lightQuote);
pen.setColor(color);
painter.setPen(pen);
painter.drawEllipse(pos, pos, lightWidth, lightWidth);
lightWidth--;
if (!lightWidth)
break;
painter.drawEllipse(pos, pos, lightWidth, lightWidth);
lightWidth--;
if (!lightWidth)
break;
painter.drawEllipse(pos, pos, lightWidth, lightWidth);
pos++;
lightWidth--;
}
//draw border
painter.setBrush(Qt::NoBrush);
int angle = -720;
color = palette().color(QPalette::Light);
for (int arc=120; arc<2880; arc+=240) {
pen.setColor(color);
painter.setPen(pen);
int w = width - pen.width()/2;
painter.drawArc(pen.width()/2, pen.width()/2, w, w, angle+arc, 240);
painter.drawArc(pen.width()/2, pen.width()/2, w, w, angle-arc, 240);
color = color.darker(110);
}
}
int HLed::ledWidth() const
{
int width = qMin(this->width(), this->height());
width -= 2;
return width > 0 ? width : 0;
}

View File

@@ -0,0 +1,34 @@
#ifndef HLED_H
#define HLED_H
#include <QWidget>
class QColor;
class HLed : public QWidget
{
Q_OBJECT
public:
HLed(QWidget *parent = 0);
~HLed();
QColor color() const;
QSize sizeHint() const;
QSize minimumSizeHint() const;
public slots:
void setColor(const QColor &color);
void toggle();
void turnOn(bool on=true);
void turnOff(bool off=true);
protected:
void paintEvent(QPaintEvent *);
int ledWidth() const;
private:
struct Private;
Private * const m_d;
};
#endif // HLED_H

View File

@@ -0,0 +1,11 @@
#include <QApplication>
#include "dialog.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Dialog w;
w.show();
return a.exec();
}

View File

@@ -0,0 +1,22 @@
#-------------------------------------------------
#
# Project created by QtCreator 2011-11-06T21:37:41
#
#-------------------------------------------------
QT += core gui
contains(QT_VERSION, ^5\\..*\\..*): QT += widgets
TARGET = uartassistant
TEMPLATE = app
include(../../src/qextserialport.pri)
SOURCES += main.cpp\
dialog.cpp\
hled.cpp
HEADERS += dialog.h \
hled.h
FORMS += dialog.ui