If anyone were to search the criminal code of the commonwealth, they will find several different laws that deal with marijuana besides simple possession. And, its a kind of pick and choose option for prosecutors to enhance things like cultivation of a small number of plants into a possession with intent to distribute. If you are growing, you should be charged with growing, not intent to distribute because until something is actually bagged and ready, its not ready to distribute. In my case, I also had a bag of dried leaves that I was using to aleviate my degenerative arthritis, not buds, and if they used these as intent to distribute, that is wrong because nobody, and I mean nobody buys leaves thinking it is bud.
The only law I could find with a quick search was
Title 35. Could you give me the links to the other relevant laws you say you found? I'd like to read them.
(g) Any person who violates clause (31) of subsection (a) is guilty of a misdemeanor and upon conviction thereof shall be sentenced to imprisonment not exceeding thirty days, or to pay a fine not exceeding not exceeding five hundred dollars ($500), or both.
(h) Any penalty imposed for violation of this act shall be in addition to, and not in lieu of, any civil or administrative penalty or sanction authorized by law.(i) Any person who violates clauses (32), (33) and (34) of subsection (a) is guilty of a misdemeanor and upon conviction thereof shall be sentenced to pay a fine not exceeding
two thousand five hundred dollars ($2,500) or to imprisonment not exceeding one (1)
year, or both.
Any person who violates clause (33) by delivering drug paraphernalia to a
person under eighteen (18) years of age who is three (3) or more years his junior shall be
guilty of a misdemeanor of the second degree and upon conviction thereof shall be
sentenced to pay a fine not exceeding five thousand dollars ($5,000) or to imprisonment
not exceeding two (2) years, or both.
Curiously by reading the above and clauses 31, 32, 33 and 34 which cover marijuana, simply growing marijuana with the intent to deliver in an amount under 30 grams,
even if to a minor appears to be a misdemeanor. From reading the statute the
only possible way you would have been convicted of a felony is if they had concrete proof you intended to make a profit. So unless one of the other laws you say you found supersedes the controlled substance act as implemented in PA, I'm still convinced your lawyer was god awful incompetent for advising you to take a felony plea before seeing any evidence.
And lastly, Pennsylvania will not allow a defendant to even bring up that is was for medical use. Time for a change we can believe in, and allow the facts to be the foundation of any marijuana charge.

That logically is the case not just for pennsylvania, but any state that does not have an exemption for medical purposes.
In a similar fashion a judge would not allow a 'The guy had blonde hair' defense for a murder trial. For there is no exemption for killing blondes in the statutes that govern murder. It has to be a valid defense under
current law. An example of an allowable defense would be, "The murder was committed in self defense, I was in fear of my life." The Judge would allow that, if that act was justified under current law.